private void buttonXEnter_Click(object sender, EventArgs e) { if (material == null) { if (!string.IsNullOrWhiteSpace(textBoxXName.Text)) { Model.Material material = new Model.Material(); material.Ma_Barcode = XYEEncoding.strCodeHex(textBoxXBarcode.Text.Trim()); material.Ma_Clear = 1; material.Ma_Code = XYEEncoding.strCodeHex(BuildCode.ModuleCode("MA")); if (dateTimeInputCreate.Text != "") { material.Ma_CreateDate = dateTimeInputCreate.Value.Date; } material.Ma_Enable = checkBoxXEnable.Checked ? 0 : 1; if (dateTimeInputInput.Text != "") { material.Ma_InDate = dateTimeInputInput.Value.Date; } material.Ma_InPrice = XYEEncoding.strCodeHex(textBoxXInPrice.Text.Trim()); material.Ma_Model = XYEEncoding.strCodeHex(textBoxXTypeModel.Text.Trim()); material.Ma_Name = XYEEncoding.strCodeHex(textBoxXName.Text.Trim()); material.Ma_PicName = ""; material.Ma_Price = XYEEncoding.strCodeHex(textBoxXOutPrice.Text.Trim()); material.Ma_PriceA = XYEEncoding.strCodeHex(textBoxXPA.Text.Trim()); material.Ma_PriceB = XYEEncoding.strCodeHex(textBoxXPB.Text.Trim()); material.Ma_PriceC = XYEEncoding.strCodeHex(textBoxXPC.Text.Trim()); material.Ma_PriceD = XYEEncoding.strCodeHex(textBoxXPD.Text.Trim()); material.Ma_PriceE = ""; material.Ma_Remark = XYEEncoding.strCodeHex(textBoxXRemark.Text.Trim()); material.Ma_RFID = XYEEncoding.strCodeHex(textBoxXRFID.Text.Trim()); if (comboBoxExSupplier.SelectedText != null && comboBoxExSupplier.SelectedValue != null) { material.Ma_SupID = XYEEncoding.strCodeHex(comboBoxExSupplier.SelectedValue.ToString()); material.Ma_Supplier = XYEEncoding.strCodeHex(comboBoxExSupplier.SelectedText); } if (comboTreeType.SelectedNode != null) { material.Ma_TypeID = XYEEncoding.strCodeHex(comboTreeType.SelectedNode.Tag.ToString()); material.Ma_TypeName = XYEEncoding.strCodeHex(comboTreeType.SelectedNode.FullPath.Replace(';', '/')); } material.Ma_Unit = XYEEncoding.strCodeHex(textBoxXUnit.Text.Trim()); material.Ma_zhujima = XYEEncoding.strCodeHex(textBoxXzhujima.Text.Trim()); MaterialManager mm = new MaterialManager(); try { int result = mm.Add(material); if (result > 0) { MessageBox.Show("新增产品成功!"); MaterialForm mf = (MaterialForm)this.Owner; mf.Isflag = true; } else { MessageBox.Show("更新失败,请检查服务器连接并尝试重新更新数据"); } Close(); } catch (Exception ex) { MessageBox.Show("新增产品出错,请检查服务器连接.错误:" + ex.Message); Close(); } } else { MessageBox.Show("货品名称不可为空,请注意 电影时间确实太短了,要把故事说全的话估计"); } } else { if (!string.IsNullOrWhiteSpace(textBoxXName.Text)) { material.Ma_Barcode = XYEEncoding.strCodeHex(textBoxXBarcode.Text.Trim()); if (dateTimeInputCreate.Text != "") { material.Ma_CreateDate = dateTimeInputCreate.Value; } if (dateTimeInputInput.Text != "") { material.Ma_InDate = dateTimeInputInput.Value; } material.Ma_InPrice = XYEEncoding.strCodeHex(textBoxXInPrice.Text.Trim()); material.Ma_Model = XYEEncoding.strCodeHex(textBoxXTypeModel.Text.Trim()); material.Ma_Name = XYEEncoding.strCodeHex(textBoxXName.Text.Trim()); material.Ma_Price = XYEEncoding.strCodeHex(textBoxXOutPrice.Text.Trim()); material.Ma_PriceA = XYEEncoding.strCodeHex(textBoxXPA.Text.Trim()); material.Ma_PriceB = XYEEncoding.strCodeHex(textBoxXPB.Text.Trim()); material.Ma_PriceC = XYEEncoding.strCodeHex(textBoxXPC.Text.Trim()); material.Ma_PriceD = XYEEncoding.strCodeHex(textBoxXPD.Text.Trim()); material.Ma_PriceE = ""; material.Ma_Remark = XYEEncoding.strCodeHex(textBoxXRemark.Text.Trim()); material.Ma_RFID = XYEEncoding.strCodeHex(textBoxXRFID.Text.Trim()); if (comboBoxExSupplier.SelectedText != null && comboBoxExSupplier.SelectedValue != null) { material.Ma_SupID = XYEEncoding.strCodeHex(comboBoxExSupplier.SelectedValue.ToString()); material.Ma_Supplier = XYEEncoding.strCodeHex(comboBoxExSupplier.SelectedText); } if (comboTreeType.SelectedNode != null) { material.Ma_TypeID = XYEEncoding.strCodeHex(comboTreeType.SelectedNode.Tag.ToString()); material.Ma_TypeName = XYEEncoding.strCodeHex(comboTreeType.SelectedNode.FullPath.Replace(';', '/')); } material.Ma_Unit = XYEEncoding.strCodeHex(textBoxXUnit.Text.Trim()); material.Ma_zhujima = XYEEncoding.strCodeHex(textBoxXzhujima.Text.Trim()); MaterialManager mm = new MaterialManager(); try { bool result = mm.Update(material); if (result) { MessageBox.Show("更新产品信息成功!"); MaterialForm mf = (MaterialForm)this.Owner; mf.Isflag = true; } else { MessageBox.Show("更新失败,请检查服务器连接并尝试重新更新数据"); } Close(); } catch (Exception ex) { MessageBox.Show("更新产品出错,请检查服务器连接.错误:" + ex.Message); Close(); } } else { MessageBox.Show("货品名称不可为空,请注意"); } } }