Beispiel #1
0
 public void AddNewItem(LawDictionaryModel lawDictionaryModel)
 {
     ShowAjax();
     LawDictionaryModels.Add(lawDictionaryModel);
     writeData();
     CloseAjax();
 }
Beispiel #2
0
        private void AddUpdateLD_Load(object sender, EventArgs e)
        {
            layoutControlGroupLD.Text = IsUpdate ? "កែប្រែឯកសារ​" : "បញ្ចូលឯកសារ​";
            if (!IsUpdate)
            {
                LawDictionaryModel = new LawDictionaryModel();
            }

            Types =
                new BindingList <string>(
                    LawDictionaryModels.OrderBy(s => s.OrderType).Select(s => s.Type).Distinct().ToList());
            Years =
                new BindingList <string>(
                    LawDictionaryModels.OrderByDescending(s => s.Year).Select(s => s.Year).Distinct().ToList());
            NGOs =
                new BindingList <string>(LawDictionaryModels.OrderBy(s => s.NGO).Select(s => s.NGO).Distinct().ToList());

            BindType();
            BindYear();
            BindNGO();

            if (LawDictionaryModel != null)
            {
                textEditName.EditValue = LawDictionaryModel.Document;
                textEditNo.EditValue   = LawDictionaryModel.Code;
                comboBoxEditType.Text  = LawDictionaryModel.Type;
                comboBoxEditYear.Text  = LawDictionaryModel.Year;
                comboBoxEditNGO.Text   = LawDictionaryModel.NGO;

                if (IsUpdate && File.Exists(dir + "Files\\" + LawDictionaryModel.ID))
                {
                    OldFile = textEditDocLocation.Text = dir + "Files\\" + LawDictionaryModel.ID;
                    textEditDocLocation.Text = OldFile;
                }
            }
        }
Beispiel #3
0
        private void AddUpdateLD_Load(object sender, EventArgs e)
        {
            layoutControlGroupLD.Text = IsUpdate ? "កែប្រែឯកសារ​" : "បញ្ចូលឯកសារ​";
            if (!IsUpdate)
            {
                LawDictionaryModel = new LawDictionaryModel();
            }

            Types =
                new BindingList<string>(
                    LawDictionaryModels.OrderBy(s => s.OrderType).Select(s => s.Type).Distinct().ToList());
            Years =
                new BindingList<string>(
                    LawDictionaryModels.OrderByDescending(s => s.Year).Select(s => s.Year).Distinct().ToList());
            NGOs =
                new BindingList<string>(LawDictionaryModels.OrderBy(s => s.NGO).Select(s => s.NGO).Distinct().ToList());

            BindType();
            BindYear();
            BindNGO();

            if (LawDictionaryModel != null)
            {
                textEditName.EditValue = LawDictionaryModel.Document;
                textEditNo.EditValue = LawDictionaryModel.Code;
                comboBoxEditType.Text = LawDictionaryModel.Type;
                comboBoxEditYear.Text = LawDictionaryModel.Year;
                comboBoxEditNGO.Text = LawDictionaryModel.NGO;

                if (IsUpdate && File.Exists(dir + "Files\\" + LawDictionaryModel.ID))
                {
                    OldFile = textEditDocLocation.Text = dir + "Files\\" + LawDictionaryModel.ID;
                    textEditDocLocation.Text = OldFile;
                }
            }
        }
Beispiel #4
0
        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();
            }
        }
Beispiel #5
0
 public void AddNewItem(LawDictionaryModel lawDictionaryModel)
 {
     ShowAjax();
     LawDictionaryModels.Add(lawDictionaryModel);
     writeData();
     CloseAjax();
 }
Beispiel #6
0
        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();
            }
        }