private void simpleButtonSave_Click(object sender, EventArgs e) { var message = ""; var newLine = ""; if (string.IsNullOrEmpty(textEditNo.Text)) { message += newLine + "* សូមបញ្ចូលលេខឯកសារ។"; newLine = "\n"; textEditNo.BackColor = Color.LightCoral; } if (string.IsNullOrEmpty(textEditName.Text)) { message += newLine + "* សូមបញ្ចូលឈ្មោះឯកសារ។"; newLine = "\n"; textEditName.BackColor = Color.LightCoral; } if (string.IsNullOrEmpty(comboBoxEditType.Text)) { message += newLine + "* សូមបញ្ចូលប្រភេទឯកសារ។"; newLine = "\n"; comboBoxEditType.BackColor = Color.LightCoral; } if (string.IsNullOrEmpty(comboBoxEditYear.Text)) { message += newLine + "* សូមបញ្ចូលឆ្នាំឯកសារ។"; newLine = "\n"; comboBoxEditYear.BackColor = Color.LightCoral; } if (string.IsNullOrEmpty(comboBoxEditNGO.Text)) { message += newLine + "* សូមបញ្ចូលក្រសួង / ស្ថាប័ន។"; newLine = "\n"; comboBoxEditNGO.BackColor = Color.LightCoral; } if (!string.IsNullOrEmpty(message)) { //kZFlyoutDialog.AlertMessage(this, message); return; } var model = new LawDictionaryModel(textEditNo.Text, textEditName.Text, comboBoxEditType.Text, comboBoxEditYear.Text, comboBoxEditNGO.Text, ""); var newFileName = dir + "Files\\" + model.ID; if (IsUpdate) { if (File.Exists(textEditDocLocation.Text)) { if (File.Exists(OldFile) && OldFile != textEditDocLocation.Text) { File.Delete(OldFile); } if (textEditDocLocation.Text != newFileName) { File.Copy(textEditDocLocation.Text, newFileName, true); } } } else { if (File.Exists(textEditDocLocation.Text)) { File.Copy(textEditDocLocation.Text, newFileName, true); } } IsSave = true; IsCloseHandled = true; if (!IsUpdate) { BaseView.AddNewItem(model); textEditName.Text = string.Empty; textEditNo.Text = string.Empty; textEditDocLocation.Text = string.Empty; comboBoxEditType.Text = string.Empty; comboBoxEditYear.Text = string.Empty; comboBoxEditNGO.Text = string.Empty; } else { LawDictionaryModel.Code = textEditNo.Text; LawDictionaryModel.Document = textEditName.Text; LawDictionaryModel.Type = comboBoxEditType.Text; LawDictionaryModel.Year = comboBoxEditYear.Text; LawDictionaryModel.NGO = comboBoxEditNGO.Text; Close(); } }