📄 produceplan.h
字号:
this->tBoxBeginDate->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],"开始日期");
this->tBoxEndDate->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],"结束日期");
this->tBoxInitStorage->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],"期初库存");
this->tBoxDemond->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],"需求数量");
this->tBoxMPS->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],"MPS数量");
this->tBoxProduceOrder->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],S"生产单数量");
this->tBoxPlanningStorage->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],"预计库存");
this->tBoxStatus->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],"状态");
this->tBoxMemo->DataBindings->Add("Text",this->ds->Tables->Item[S"主生产计划表"],"备注");
}
//-----------------设置控件属性-----------------------
void SetModify(bool isModifiable)
{
this->tBoxMaterialIDShow->ReadOnly = !isModifiable;
this->tBoxMaterialName->ReadOnly = !isModifiable;
this->tBoxYearShow->ReadOnly = !isModifiable;
this->tBoxPlanDateShow->ReadOnly = !isModifiable;
this->tBoxBeginDate->ReadOnly = !isModifiable;
this->tBoxEndDate->ReadOnly = !isModifiable;
this->tBoxInitStorage->ReadOnly = !isModifiable;
this->tBoxDemond->ReadOnly = !isModifiable;
this->tBoxMPS->ReadOnly = !isModifiable;
this->tBoxProduceOrder->ReadOnly = !isModifiable;
this->tBoxPlanningStorage->ReadOnly = !isModifiable;
this->tBoxMemo->ReadOnly = !isModifiable;
//编辑时允许选择物料和工厂日历
this->btnSearchID->Enabled = isModifiable;
this->btnSearchYear->Enabled = isModifiable;
//编辑时不允许搜索
this->btnSearch->Enabled = !isModifiable;
}
//搜索主生产计划表
private: System::Void btnSearch_Click(System::Object * sender, System::EventArgs * e)
{
String* strMaterialID = this->tBoxMaterialID->Text->Trim();
String* strYear = this->tBoxYear->Text->Trim();
String* strPlanDate = this->tBoxPlanDate->Text->Trim();
String* Filter = S"";
if(String::Compare(strMaterialID,String::Empty) != 0)
{
Filter = String::Format(S"{0} AND (主生产计划.物料编号 LIKE '%{1}%')",Filter,strMaterialID);
}
if(String::Compare(strYear,String::Empty) != 0)
{
Filter = String::Format(S"{0} AND (主生产计划.年份 = {1})",Filter,strYear);
}
if(String::Compare(strPlanDate,String::Empty) != 0)
{
Filter = String::Format(S"{0} AND (主生产计划.计划期 = {1})",Filter,strPlanDate);
}
if(String::Compare(Filter,String::Empty) != 0)
{
Filter = Filter->Substring(5,Filter->Length - 5);
this->ProduceAdapter->SelectCommand->CommandText = String::Format(S"SELECT 物料主文件.物料名称,主生产计划.* FROM 主生产计划 INNER JOIN 物料主文件 ON 主生产计划.物料编号 = 物料主文件.物料编号 Where {0} ",Filter);
this->ds->Tables->Item[S"主生产计划表"]->Clear();
this->ProduceAdapter->Fill(this->ds,S"主生产计划表");
this->SetModify(false);
}
}
//选择物料
private: System::Void btnSearchID_Click(System::Object * sender, System::EventArgs * e)
{
SelectMaterials* newFrm = new SelectMaterials();
if(newFrm->ShowDialog(this) == DialogResult::OK)
{
this->tBoxMaterialID->Text = newFrm->SeletedMaterialID;
this->tBoxMaterialName->Text = newFrm->SeletedMaterialName;
}
}
//选择工厂日历
private: System::Void btnSearchYear_Click(System::Object * sender, System::EventArgs * e)
{
FactorySchedule* newFrm = new FactorySchedule(true);
if(newFrm->ShowDialog(this) == DialogResult::OK)
{
this->tBoxYearShow->Text = newFrm->Year;
this->tBoxBeginDate->Text = newFrm->BeginDate;
this->tBoxEndDate->Text = newFrm->EndDate;
this->tBoxPlanDateShow->Text = newFrm->PlanDate;
}
}
//导航条
private: System::Void toolBar1_ButtonClick(System::Object * sender, System::Windows::Forms::ToolBarButtonClickEventArgs * e)
{
if(String::Compare(e->Button->ToolTipText->Trim(),S"首记录") == 0)
{
this->dgrdProducePlan->UnSelect(this->cmProduce->Position);
this->cmProduce->Position = 0;
this->dgrdProducePlan->Select(this->cmProduce->Position);
this->dgrdProducePlan->CurrentRowIndex = this->cmProduce->Position;
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"上一记录") == 0)
{
if(this->cmProduce->Position > 0)
{
this->dgrdProducePlan->UnSelect(this->cmProduce->Position);
this->cmProduce->Position--;
this->dgrdProducePlan->Select(this->cmProduce->Position);
this->dgrdProducePlan->CurrentRowIndex = this->cmProduce->Position;
}
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"下一记录") == 0)
{
if(this->cmProduce->Position < this->cmProduce->Count - 1)
{
this->dgrdProducePlan->UnSelect(this->cmProduce->Position);
this->cmProduce->Position++;
this->dgrdProducePlan->Select(this->cmProduce->Position);
this->dgrdProducePlan->CurrentRowIndex = this->cmProduce->Position;
}
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"尾记录") == 0)
{
this->dgrdProducePlan->UnSelect(this->cmProduce->Position);
this->cmProduce->Position = this->cmProduce->Count - 1;
this->dgrdProducePlan->Select(this->cmProduce->Position);
this->dgrdProducePlan->CurrentRowIndex = this->cmProduce->Position;
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"新增记录") == 0)
{
//显示物料选择窗口
SelectMaterials* newFrm = new SelectMaterials();
if(newFrm->ShowDialog(this) == DialogResult::OK)
{
//如果选择了物料则添加新记录
this->cmProduce->AddNew();
this->tBoxMaterialIDShow->Text = newFrm->SeletedMaterialID;
this->tBoxMaterialName->Text = newFrm->SeletedMaterialName;
//默认状态为正常
this->tBoxStatus->Text = S"正常";
this->tBoxInitStorage->Text = S"0";
this->tBoxDemond->Text = S"0";
this->tBoxMPS->Text = S"0";
this->tBoxYearShow->Text = S"2005";
this->tBoxPlanDateShow->Text = S"2005";
this->SetModify(true);
this->cmProduce->EndCurrentEdit();
System::Windows::Forms::SendKeys::Send("{Tab}");
}
else
{
//如果没有选择物料则返回
return;
}
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"修改记录") == 0)
{
this->SetModify(true);
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"删除记录") == 0)
{
if(MessageBox::Show(S"删除这条记录?",S"删除",MessageBoxButtons::OKCancel) == DialogResult::OK)
{
if(this->cmProduce->Count > 0)
{
int row = this->cmProduce->Position;
String* ProduceID = this->ds->Tables->Item[S"主生产计划表"]->Rows->Item[row]->Item[S"编号"]->ToString();
String* tempSQL = String::Format(S"Delete from 主生产计划 where 编号 = '{0}'",ProduceID);
this->MyDataBase->SQLOperate(tempSQL);
this->cmProduce->RemoveAt(this->cmProduce->Position);
this->cmProduce->EndCurrentEdit();
this->SetModify(false);
}
}
else
{
MessageBox::Show(S"表中无可删除数据",S"提示");
}
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"保存修改") == 0)
{
if(String::Compare(this->tBoxMaterialIDShow->Text,String::Empty) == 0)
{
MessageBox::Show(S"物料编号不能为空");
return;
}
if(String::Compare(this->tBoxMPS->Text,String::Empty) == 0)
{
MessageBox::Show(S"MPS数量不能为空");
return;
}
if(String::Compare(this->tBoxPlanDateShow->Text,String::Empty) == 0)
{
MessageBox::Show(S"计划期不能为空");
return;
}
this->cmProduce->EndCurrentEdit();
this->MyDataBase->UpdateDataBase(this->ProduceAdapter,this->ds,S"主生产计划表");
this->MyDataBase->UpdateDataBase(this->DemandAdapter,this->ds,S"主需求计划表");
this->SetModify(false);
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"取消修改") == 0)
{
this->cmProduce->CancelCurrentEdit();
this->SetModify(false);
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"退出") == 0)
{
this->Close();
}
}
private: System::Void dgrdProducePlan_Click(System::Object * sender, System::EventArgs * e)
{
//点击其它记录则不可编辑
this->SetModify(false);
}
private: System::Void btnImport_Click(System::Object * sender, System::EventArgs * e)
{
if(this->ds->Tables->Item[S"主需求计划表"]->Rows->Count == 0)
{
return;
}
int row = this->dgrdDemondPlan->CurrentRowIndex;
String* Year = this->ds->Tables->Item[S"主需求计划表"]->Rows->Item[row]->Item[S"年份"]->ToString();
String* ID = this->ds->Tables->Item[S"主需求计划表"]->Rows->Item[row]->Item[S"物料编号"]->ToString();
String* Plan = this->ds->Tables->Item[S"主需求计划表"]->Rows->Item[row]->Item[S"计划期"]->ToString();
//从选择的主需求计划导入主生产计划
String* tempSQL = String::Format(S"INSERT INTO 主生产计划([物料编号], [年份], [计划期], [开始日期], [结束日期], [MPS数量], [需求数量], [状态], [备注]) SELECT 物料编号, 年份, 计划期, 开始日期, 结束日期, 需求数量, 需求数量, 状态, 备注 FROM 主需求计划 WHERE (年份 = {0}) AND (物料编号 = {1}) AND (计划期 = {2})",Year,ID,Plan);
this->MyDataBase->SQLOperate(tempSQL);
//删除选择的主需求计划
this->ds->Tables->Item[S"主需求计划表"]->Rows->Item[row]->Delete();
this->MyDataBase->UpdateDataBase(this->DemandAdapter,this->ds,S"主需求计划表");
//刷新数据表
this->ds->Tables->Item[S"主生产计划表"]->Clear();
this->ProduceAdapter->Fill(this->ds,S"主
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -