/* New Form with selected Mode */ public AddWarehouseImage(models.WarehouseImageModel model) { this.model = model; //this.comboMenageNo.Enabled = true; //this.comboMemberCode.Enabled = false; //this.comboMenageNo.DropDownStyle = ComboBoxStyle.DropDownList; InitializeComponent(); //this.comboMemberCode.Enabled = false; }
private void btnSave_Click(object sender, EventArgs e) { if (model == null) // add Industrial mode { model = new models.WarehouseImageModel(); //new model to assign data model.manageNo = comboMenageNo.Text.Trim(); // set province id model.Code = comboMemberCode.Text.Trim(); model.img01 = imgBrowse1.FileName != "imgBrowse1" ? imgBrowse1.SafeFileName : ""; //set file name model.img02 = ImgBrowse2.FileName != "imgBrowse2" ? ImgBrowse2.SafeFileName : ""; //set file name model.img03 = ImgBrowse3.FileName != "imgBrowse3" ? ImgBrowse3.SafeFileName : ""; //set file name model.img04 = ImgBrowse4.FileName != "imgBrowse4" ? ImgBrowse4.SafeFileName : ""; //set file name model.img05 = ImgBrowse5.FileName != "imgBrowse5" ? ImgBrowse5.SafeFileName : ""; //set file name WarehouseImageController.InsertData(model); // call update method model = null; } else // update (edit) Industrial mode { model = new models.WarehouseImageModel(); //new model to assign data model.manageNo = comboMenageNo.Text.Trim(); // set province id model.Code = comboMemberCode.Text.Trim(); model.img01 = imgBrowse1.FileName != "imgBrowse1" ? imgBrowse1.SafeFileName : ""; //set file name model.img02 = ImgBrowse2.FileName != "imgBrowse2" ? ImgBrowse2.SafeFileName : ""; //set file name model.img03 = ImgBrowse3.FileName != "imgBrowse3" ? ImgBrowse3.SafeFileName : ""; //set file name model.img04 = ImgBrowse4.FileName != "imgBrowse4" ? ImgBrowse4.SafeFileName : ""; //set file name model.img05 = ImgBrowse5.FileName != "imgBrowse5" ? ImgBrowse5.SafeFileName : ""; //set file name WarehouseImageController.UpdateData(model); // call update method } if (imgBrowse1.FileName != "imgBrowse1" || ImgBrowse2.FileName != "imgBrowse2" || ImgBrowse3.FileName != "imgBrowse3" || ImgBrowse4.FileName != "imgBrowse4" || ImgBrowse5.FileName != "imgBrowse5") // Check if picture has selected { // Copy file to image folder in this project if (imgBrowse1.FileName != null && imgBrowse1.FileName.Equals(String.Empty)) { System.IO.File.Copy(imgBrowse1.FileName, Properties.Settings.Default.ImagePath + imgBrowse1.SafeFileName, true); } if (ImgBrowse2.FileName != null && ImgBrowse2.FileName.Equals(String.Empty)) { System.IO.File.Copy(ImgBrowse2.FileName, Properties.Settings.Default.ImagePath + ImgBrowse2.SafeFileName, true); } if (ImgBrowse3.FileName != null && ImgBrowse3.FileName.Equals(String.Empty)) { System.IO.File.Copy(ImgBrowse3.FileName, Properties.Settings.Default.ImagePath + ImgBrowse3.SafeFileName, true); } if (ImgBrowse4.FileName != null && ImgBrowse4.FileName.Equals(String.Empty)) { System.IO.File.Copy(ImgBrowse4.FileName, Properties.Settings.Default.ImagePath + ImgBrowse4.SafeFileName, true); } if (ImgBrowse4.FileName != null && ImgBrowse4.FileName.Equals(String.Empty)) { System.IO.File.Copy(ImgBrowse5.FileName, Properties.Settings.Default.ImagePath + ImgBrowse5.SafeFileName, true); } } }
public static void UpdateData(models.WarehouseImageModel model) { //show message box when cannot insert data MessageBox.Show((models.WarehouseImageModel.updateWarehouseImage(model)) ? "Insert Success" : "Insert Failed, Please Check parameter or something"); }