Пример #1
0
        public ActionResult Edit(MeasureModel Model)
        {
            if (string.IsNullOrEmpty(Model.id.ToString()))
            {
                TempData["Error"] = "Data has already been deleted by other user!";
                return(RedirectToAction("Index"));
            }
            List <string> lstMsg     = new List <string>();
            int           returnCode = _measureBLL.Update(Model, out lstMsg);

            if (ModelState.IsValid)
            {
                if (!((int)Common.ReturnCode.Succeed == returnCode))
                {
                    if (lstMsg != null)
                    {
                        for (int i = 0; i < lstMsg.Count(); i++)
                        {
                            ModelState.AddModelError(string.Empty, lstMsg[i]);
                        }
                    }
                    return(View(Model));
                }
                TempData["Success"] = "Updated Successfully!";
                return(RedirectToAction("View", new { @id = Model.id }));
            }
            return(View());
        }
Пример #2
0
        private void SaveData()
        {
            // check xem có trong db chưa?
            string  measureId = txtMeasureId.Text.Trim();
            Measure measure   = new Measure();

            measure = measureBLL.GetMeasureWithID(measureId);

            measureSea = new Measure();

            measureSea.MeasureId   = txtMeasureId.Text;
            measureSea.ProductId   = cboProduct.SelectedValue.ToString();
            measureSea.MeasureNote = rtbNote.Text;


            if (measure != null)
            {// Cập nhật
                if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CommonCodeUpdate"),
                                                                     Common.clsLanguages.GetResource("Information"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                {
                    int i = measureBLL.Update(measureSea);
                    if (i == 1)
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("UpdateSuccess1");
                        //proSea.Image = pro.Image;
                    }
                    else
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("UpdateNoSuccess1");
                    }
                }
            }
            else
            {// Thêm mới
                if (CustomMessageBox.MessageBox.ShowCustomMessageBox(Common.clsLanguages.GetResource("CommonCodeCreate"),
                                                                     Common.clsLanguages.GetResource("Information"),
                                                                     Common.Config.CUSTOM_MESSAGEBOX_ICON.Information,
                                                                     Common.Config.CUSTOM_MESSAGEBOX_BUTTON.YESNO) == DialogResult.Yes)
                {
                    measureId            = measureBLL.Tao_ProductID();
                    measureSea.MeasureId = measureId;

                    int i = measureBLL.Insert(measureSea);
                    if (i == 1)
                    {
                        lblTB1.Text       = Common.clsLanguages.GetResource("InsertSuccess1");
                        txtMeasureId.Text = measureId;
                        //proSea.Image = null;
                    }
                    else
                    {
                        lblTB1.Text = Common.clsLanguages.GetResource("InsertNoSuccess1");
                    }
                }
            }


            SearchMeasures(1);
        }