private void form_save_Click(object sender, EventArgs e) { if (_MaterialType == null) { MaterialType materialType = new MaterialType() { MT_Name = textBox1.Text.Trim(), MT_ParentID = _MType_Code, MT_Clear = 1, MT_Enable = 1, MT_Code = BuildCode.ModuleCode("MT") }; try { int result = mtm.Add(materialType); MaterialForm materialForm = (MaterialForm)this.Owner; if (result > 0) { materialForm.Isflag = true; MessageBox.Show("地区名称:" + textBox1.Text + " \n添加成功"); Close(); } else { materialForm.Isflag = false; MessageBox.Show("添加失败,请重新添加"); Close(); } } catch (Exception ex) { MessageBox.Show("新增地区资料错误,请检查服务器连接.错误信息:" + ex.Message); } } else { _MaterialType.MT_Name = textBox1.Text.Trim(); try { bool result = mtm.UpdateByCode(_MaterialType); if (result) { MaterialForm materialForm = (MaterialForm)this.Owner; materialForm.Isflag = true; MessageBox.Show("地区名称:" + textBox1.Text + " \n修改成功"); Close(); } else { MaterialForm materialForm = (MaterialForm)this.Owner; materialForm.Isflag = false; MessageBox.Show("修改失败,请重新修改"); Close(); } } catch (Exception ex) { MessageBox.Show("新增地区资料错误,请检查服务器连接.错误信息:" + ex.Message); } } }
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("货品名称不可为空,请注意"); } } }