📄 stocktable.h
字号:
if(i == 0 || i == 1)
{
aColumnTextColumn->ReadOnly = true;
}
if(i == 2)
{
aColumnTextColumn->get_TextBox()->add_DoubleClick(new EventHandler(this,WareIDDoubleClickHandler));
aColumnTextColumn->MappingName = this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName;
aColumnTextColumn->HeaderText = String::Format(S"{0}(双击)",this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName);
aColumnTextColumn->NullText = String::Empty;
}
else if(i == 10)
{
aColumnTextColumn->get_TextBox()->add_DoubleClick(new EventHandler(this,StorageIDDoubleClickHandler));
aColumnTextColumn->MappingName = this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName;
aColumnTextColumn->HeaderText = String::Format(S"{0}(双击)",this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName);
aColumnTextColumn->NullText = String::Empty;
}
else if(i == 3)
{
//进货数量
aColumnTextColumn->get_TextBox()->Enabled = false;
aColumnTextColumn->MappingName = this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName;
aColumnTextColumn->HeaderText = this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName;
aColumnTextColumn->NullText = String::Empty;
}
else
{
aColumnTextColumn->MappingName = this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName;
aColumnTextColumn->HeaderText = this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName;
aColumnTextColumn->NullText = String::Empty;
}
//显示库存
aColumnTextColumn->get_TextBox()->add_Enter(new EventHandler(this,StorageHandler));
//设为数字格式显示
aColumnTextColumn->Format = S"N";
ts->GridColumnStyles->Add(aColumnTextColumn);
}
}
else
{
DataGridNoActiveCellColumn* aColumnTextColumn;
for(int i = 0;i < numCols;i++)
{
aColumnTextColumn = new DataGridNoActiveCellColumn();
aColumnTextColumn->MappingName = this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName;
aColumnTextColumn->HeaderText = this->ds->Tables->Item[S"进货单明细"]->Columns->Item[i]->ColumnName;
aColumnTextColumn->NullText = String::Empty;
aColumnTextColumn->Format = S"N";
ts->GridColumnStyles->Add(aColumnTextColumn);
}
}
this->dgrdImportTable->TableStyles->Add(ts);
}
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{
this->SetStocker();
}
private: System::Void toolBar1_ButtonClick(System::Object * sender, System::Windows::Forms::ToolBarButtonClickEventArgs * e)
{
//查看进货单
if(String::Compare(e->Button->ToolTipText,S"查看") == 0)
{
SelectImportTable* tempFrm = new SelectImportTable(NULL);
if(tempFrm->ShowDialog(this) == DialogResult::OK)
{
String* tempSQL;
String* tempTable;
//清除旧的查询
//用ds->Clear()只能清除ds中的数据
ds->Tables->Clear();
this->dgrdImportTable->TableStyles->Clear();
//查询进货单明细
this->intImportID = System::Int32::Parse(tempFrm->SendImportID->Trim());
this->strSQL = String::Format("Select * from 进货单明细 where 进货单号 = '{0}'",this->intImportID.ToString());
this->strTableName = S"进货单明细";
this->MyDataBase->SelectDataBase(this->ImportDetailAdpater,this->ds,this->strSQL,this->strTableName);
this->dgrdImportTable->DataSource = ds->Tables->Item[S"进货单明细"];
//查询进货单
this->strSQL = String::Format("Select * from 进货单 where 编号 = '{0}'",tempFrm->SendImportID);
this->strTableName = S"进货单";
this->MyDataBase->SelectDataBase(this->ImportTableAdpater,this->ds,this->strSQL,this->strTableName);
//查询库存
this->strSQL = new String("Select * from 库存库");
this->strTableName = S"库存";
this->MyDataBase->SelectDataBase(this->StorageAdpater,this->ds,this->strSQL,this->strTableName);
//查询供货商
tempSQL = String::Format("Select * from 供货商清单 where 供货商号 = '{0}'",this->ds->Tables->Item[S"进货单"]->Rows->Item[0]->Item[S"供货商号"]->ToString()->Trim());
tempTable = S"供货商清单";
this->MyDataBase->SelectDataBase(this->ds,tempSQL,tempTable);
//设置进货单信息
this->tBoxImportDate->Text = this->ds->Tables->Item[S"进货单"]->Rows->Item[0]->Item[S"进货日期"]->ToString()->Trim();
this->tBoxMaker->Text = this->ds->Tables->Item[S"进货单"]->Rows->Item[0]->Item[S"制单人"]->ToString()->Trim();
this->cmbOperator->Text = this->ds->Tables->Item[S"进货单"]->Rows->Item[0]->Item[S"业务员"]->ToString()->Trim();
this->tBoxStockerID->Text = this->ds->Tables->Item[S"供货商清单"]->Rows->Item[0]->Item[S"供货商号"]->ToString()->Trim();
this->tBoxStockerName->Text = this->ds->Tables->Item[S"供货商清单"]->Rows->Item[0]->Item[S"名称"]->ToString()->Trim();
//设置数据表
this->DataGridStateControl(false);
this->dgrdImportTable->DataSource = ds->Tables->Item[S"进货单明细"];
//查看时不能更改进货单
this->dgrdImportTable->ReadOnly = true;
this->dgrdImportTable->Enabled = true;
this->button1->Enabled = false;
//设置工具栏
this->tbarSave->Enabled = false;
this->tbarDelete->Enabled = true;
}
}
//新建进货单
else if(String::Compare(e->Button->ToolTipText,S"新建") == 0)
{
//清除旧的查询
ds->Tables->Clear();
this->dgrdImportTable->TableStyles->Clear();
String* tempSQL = new String("Select 编号 from 进货单");
SqlCommand* sqlCmd = new SqlCommand(tempSQL,this->MyDataBase->myConnection);
SqlDataReader* reader = sqlCmd->ExecuteReader();
//设置新进货单的编号
intImportID = 0;
while(reader->Read())
{
if(intImportID < System::Int32::Parse(reader->Item[0]->ToString()))
intImportID = System::Int32::Parse(reader->Item[0]->ToString());
}
intImportID++;
//设置明细条目的编号
reader->Dispose();
sqlCmd->CommandText = new String("Select 编号 from 进货单明细");
reader = sqlCmd->ExecuteReader();
NewDetailID = 0;
while(reader->Read())
{
if(NewDetailID < System::Int32::Parse(reader->Item[0]->ToString()))
NewDetailID = System::Int32::Parse(reader->Item[0]->ToString());
}
NewDetailID++;
reader->Close();
//查询进货单明细
this->strSQL = String::Format("Select * from 进货单明细 where 进货单号 = '{0}'",this->intImportID.ToString());
this->strTableName = S"进货单明细";
this->MyDataBase->SelectDataBase(this->ImportDetailAdpater,this->ds,this->strSQL,this->strTableName);
//查询进货单
this->strSQL = String::Format("Select * from 进货单 where 编号 = '{0}'",this->intImportID.ToString());
this->strTableName = S"进货单";
this->MyDataBase->SelectDataBase(this->ImportTableAdpater,this->ds,this->strSQL,this->strTableName);
//查询库存
this->strSQL = new String("Select * from 库存库");
this->strTableName = S"库存";
this->MyDataBase->SelectDataBase(this->StorageAdpater,this->ds,this->strSQL,this->strTableName);
//设置数据表
this->DataGridStateControl(true);
this->dgrdImportTable->DataSource = ds->Tables->Item[S"进货单明细"];
//新建进货单
DataRow* NewImportTableRow = this->ds->Tables->Item[S"进货单"]->NewRow();
NewImportTableRow->set_Item(S"编号",__box(intImportID));
this->ds->Tables->Item[S"进货单"]->Rows->Add(NewImportTableRow);
//在进货单明细中添加一行
//DataRow* NewImportDetailRow = this->ds->Tables->Item[S"进货单明细"]->NewRow();
//NewImportDetailRow->set_Item(S"进货单号",__box(intImportID));
//this->ds->Tables->Item[S"进货单明细"]->Rows->Add(NewImportDetailRow);
//设置进货单信息
this->SetcmbOperator();
//可以修改进货单
this->dgrdImportTable->ReadOnly = false;
this->dgrdImportTable->Enabled = true;
this->button1->Enabled = true;
//设置工具栏
this->tbarSave->Enabled = true;
this->tbarDelete->Enabled = false;
//设置显示
this->tBoxMaker->Text = S"";
this->tBoxStockerID->Text = S"";
this->tBoxStockerName->Text = S"";
this->tBoxStorage->Text = S"";
this->tBoxTotal->Text = S"";
this->tBoxTax->Text = S"";
this->tBoxTotalNoTax->Text = S"";
this->tBoxWareID->Text = S"";
}
//保存数据
else if(String::Compare(e->Button->ToolTipText,S"保存修改") == 0)
{
try
{
//更新进货单
if(String::Compare(this->tBoxStockerID->Text,String::Empty) == 0)
{
MessageBox::Show(S"请选择供货商",S"提示");
return;
}
String* Filter = String::Format(S"编号 = '{0}'",__box(this->intImportID));
DataRow* rows[] = this->ds->Tables->Item[S"进货单"]->Select(Filter);
rows[0]->Item[S"供货商号"] = this->InputStockerID;
rows[0]->Item[S"进货日期"] = this->tBoxImportDate->Text;
rows[0]->Item[S"制单人"] = this->tBoxMaker->Text;
rows[0]->Item[S"业务员"] = this->cmbOperator->Text;
rows[0]->Item[S"税价合计"] = __box(System::Double::Parse(this->tBoxTotal->Text));
rows[0]->Item[S"不含税价"] = __box(System::Double::Parse(this->tBoxTotalNoTax->Text));
rows[0]->Item[S"税额"] = __box(System::Double::Parse(this->tBoxTax->Text));
this->MyDataBase->UpdateDataBase(this->ImportTableAdpater,this->ds,S"进货单");
//更新进货单明细
for(int i = 0;i < this->ds->Tables->Item[S"进货单明细"]->Rows->Count;i++)
{
//更新编号
this->ds->Tables->Item[S"进货单明细"]->Rows->Item[i]->set_Item(S"编号",__box(this->NewDetailID + i));
//String* temp = this->ds->Tables->Item[S"进货单明细"]->Rows->Item[i]->Item[S"税价合计"]->ToString();
}
int row = this->dgrdImportTable->CurrentCell.RowNumber;
int col = this->dgrdImportTable->CurrentCell.ColumnNumber;
this->dgrdImportTable->CurrentCell = DataGridCell(row + 1,col);
if(this->ds->HasChanges())
this->ImportDetailAdpater->Update(this->ds->GetChanges(),S"进货单明细");
this->ds->Tables->Item[S"进货单明细"]->AcceptChanges();
//更新库存
// if(this->ds->HasChanges())
// this->StorageAdpater->Update(this->ds->GetChanges(),S"库存");
//this->ds->AcceptChanges();
}
catch(Exception* e)
{
String* temp = String::Format("{0}: {1}",e->get_Source(),e->Message);
MessageBox::Show(temp,S"错误");
return;
}
MessageBox::Show(S"数据修改成功!",S"提示");
}
else if(String::Compare(e->Button->ToolTipText,S"打印") == 0)
{
ImportReportForm* tempFrm = new ImportReportForm(this->intImportID.ToString());
tempFrm->ShowDialog(this);
String* tempSQL = S"exec sf_进货单";
this->MyDataBase->SQLOperate(tempSQL);
NewImportTable();
}
else if(String::Compare(e->Button->ToolTipText,S"删除") == 0)
{
/*if(MessageBox::Show(S"确实要删除进货单吗?",S"询问",MessageBoxButtons::YesNo) == DialogResult::Yes)
{
String* tempSQL;
try
{
tempSQL = String::Format(S"Delete 进货单明细 where 进货单号 = '{0}'",this->intImportID.ToString());
this->MyDataBase->SQLOperate(tempSQL);
tempSQL = String::Format(S"Delete 进货单 where 编号 = '{0}'",this->intImportID.ToString());
this->MyDataBase->SQLOperate(tempSQL);
this->ds->Clear();
//设置进货单信息
this->tBoxImportDate->Text = S"";
this->tBoxMaker->Text = S"";
this->cmbOperator->Text = S"";
this->tBoxStockerID->Text = S"";
this->tBoxStockerName->Text = S"";
//查看时不能更改进货单
this->dgrdImportTable->ReadOnly = false;
this->dgrdImportTable->Enabled = false;
this->button1->Enabled = true;
//设置工具栏
this->tbarSave->Enabled = true;
this->tbarDelete->Enabled = false;
}
catch(Exception* e)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -