public int UpdateObj(SoundIntConfig obj)
        {
            int kq = 0;

            try
            {
                string sql = "update SOUND_IntConfig set Name = N'" + obj.Name + "', Description=N'" + obj.Description + "', Formula= N'" + obj.Formula + "', IsActive='" + obj.IsActive + "',  Code='" + obj.Code + "', IsProductivity='" + obj.IsProductivity + "' where Id =" + obj.Id + " and IsDeleted=0";
                kq = dbclass.TruyVan_XuLy(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(kq);
        }
        public int AddObj(SoundIntConfig obj)
        {
            int kq = 0;

            try
            {
                string sql = "insert into SOUND_IntConfig(Name, Description, Formula, IsActive, Code, IsProductivity) values(N'" + obj.Name + "', N'" + obj.Description + "', N'" + obj.Formula + "', '" + obj.IsActive + "','" + obj.Code + "', '" + obj.IsProductivity + "' )";
                kq = dbclass.TruyVan_XuLy(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(kq);
        }
Esempio n. 3
0
        private SoundIntConfig BuilModel()
        {
            SoundIntConfig model = null;

            try
            {
                if (string.IsNullOrEmpty(txtCode.Text))
                {
                    MessageBox.Show("Lỗi: Mã cấu hình không được để trống.");
                }
                else if (string.IsNullOrEmpty(txtName.Text))
                {
                    MessageBox.Show("Lỗi: Tên cấu hình không được để trống.");
                }
                else if (string.IsNullOrEmpty(txtFormula.Text))
                {
                    MessageBox.Show("Lỗi: Công thức không được để trống");
                }
                else
                {
                    model                = new SoundIntConfig();
                    model.Code           = "[|" + txtCode.Text + "]";
                    model.IsActive       = chkIsActive.Checked;
                    model.Id             = idConfig;
                    model.Name           = txtName.Text;
                    model.Description    = txtDescription.Text;
                    model.Formula        = txtFormula.Text;
                    model.IsProductivity = chkIsXetNangSuat.Checked;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(model);
        }
Esempio n. 4
0
 private void butSaveMailSend_Click(object sender, EventArgs e)
 {
     try
     {
         SoundIntConfig model = BuilModel();
         if (model != null)
         {
             int result = 0;
             if (idConfig == 0)
             {
                 result = soundIntConfigDAO.AddObj(model);
             }
             else
             {
                 result = soundIntConfigDAO.UpdateObj(model);
             }
             if (result > 0)
             {
                 MessageBox.Show("Lưu dữ liệu thành công.");
                 LoadDataToGridView();
                 idConfig = 0;
                 ClearInput();
                 EnableControlSend(true, false, false, false, false);
                 EnableInputMSend(false);
             }
             else
             {
                 MessageBox.Show("Lưu dữ liệu thất bại.");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: " + ex.Message);
     }
 }