using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; using QMAPP.FJC.Entity.Operation; using QMAPP.ServicesAgent; using QMAPP.FJC.Entity.BZD; using QMAPP.Entity; namespace QMAPP.WinForm.Forms.Operation { /// /// /// public partial class SignInfoForm : Form { //获取服务代理 QMAPP.ServicesAgent.ServiceAgent _agent = ClientContext.GetServiceAgent(); List _bzdConfig = new List(); private SignInfo signInfo = new SignInfo(); private string Locs = string.Empty; /// /// /// /// public SignInfoForm(string loc) { InitializeComponent(); infolabel.Text = ""; infolabel.ForeColor = Color.Red; Locs = loc; PrintForm_Load(); } #region 打印按钮 /// /// 打印按钮 /// /// /// private void button1_Click(object sender, EventArgs e) { try { if (string.IsNullOrWhiteSpace(cbMaterial.Text)) { infolabel.Text = "请选择标记类型!"; cbMaterial.Focus(); return; } signInfo.ProductCode = txtMainCode.Text; signInfo.WorkLoc = Locs; signInfo.Type = cbMaterial.Text; var T = _agent.InvokeServiceFunction(B9IPCService.SignInfoBLL_GetAllListByLoc.ToString(), Locs); if (cbMaterial.Text == T.Type) { if (cbMaterial.Text == "配胶") { infolabel.Text = "请先进行清胶,才能配胶!"; cbMaterial.Focus(); return; } if (cbMaterial.Text == "清胶") { infolabel.Text = "请先进行配胶,才能清胶!"; cbMaterial.Focus(); return; } } if (cbMaterial.Text == "表皮新料" && string.IsNullOrEmpty(txtMainCode.Text)) { infolabel.Text = "表皮新料,条码不能为空!"; cbMaterial.Focus(); return; } if (cbMaterial.Text == "停工&复工") { signInfo.SIGNDATE = dtpCREATEDATESTART.Text; signInfo.Type = "停工"; _agent.InvokeServiceFunction>(B9IPCService.SignInfoBLL_Insert.ToString(), signInfo); signInfo.SIGNDATE = dtpCREATEDATEEND.Text; signInfo.Type = "复工"; _agent.InvokeServiceFunction>(B9IPCService.SignInfoBLL_Insert.ToString(), signInfo); infolabel.Text = "保存成功!"; this.dtpCREATEDATESTART.Text = ""; this.dtpCREATEDATEEND.Text = ""; return; } else { var result = _agent.InvokeServiceFunction>(B9IPCService.SignInfoBLL_Insert.ToString(), signInfo); if (result.Result > 0) { infolabel.Text = "保存成功!"; txtMainCode.Text = ""; return; } } } catch (Exception exception) { MessageBox.Show("提交失败!"); throw; } } #endregion #region 初始界面 /// /// /// /// /// private void PrintForm_Load() { _bzdConfig.Add(new Config { PID = "配胶", MATERIALCODDE = "配胶" }); _bzdConfig.Add(new Config { PID = "清胶", MATERIALCODDE = "清胶" }); _bzdConfig.Add(new Config { PID = "表皮新料", MATERIALCODDE = "表皮新料" }); //停工时间&复工 _bzdConfig.Add(new Config { PID = "停工&复工", MATERIALCODDE = "停工&复工" }); LoadAssyMaterial(); } #endregion #region 加载总成物料 /// /// 加载总成物料 /// private void LoadAssyMaterial() { //模腔号 this.cbMaterial.DataSource = _bzdConfig; this.cbMaterial.DisplayMember = "MATERIALCODDE"; this.cbMaterial.ValueMember = "PID"; } /// /// /// public class Config{ /// /// /// public string PID { get; set; } /// /// /// public string MATERIALCODDE { get; set; } } #endregion /// /// 回车事件 /// /// /// private void txtCode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter)//如果输入的是回车键 { button1_Click(sender, e);//触发button事件 } } private void cbMaterial_SelectedIndexChanged(object sender, EventArgs e) { if (cbMaterial.Text == "停工&复工") { this.txtMainCode.Enabled = false; this.dtpCREATEDATESTART.Enabled = true; this.dtpCREATEDATEEND.Enabled = true; this.dtpCREATEDATESTART.ShowUpDown = true; } else { this.txtMainCode.Enabled = true; this.dtpCREATEDATESTART.Enabled = false; this.dtpCREATEDATEEND.Enabled = false; } } } }