Beispiel #1
0
 private void butSave_Click(object sender, EventArgs e)
 {
     try
     {
         TurnCOMMng config = BuildModel();
         if (config != null)
         {
             int result = 0;
             if (configId == 0)
             {
                 result = turnCOMMngDAO.AddObj(config);
             }
             else
             {
                 result = turnCOMMngDAO.UpdateObj(config);
             }
             if (result == 1)
             {
                 MessageBox.Show("Lưu thông tin thành công.");
                 configId = 0;
                 EnableControl(true, false, false, false, false);
                 EnableInput(false);
                 LoadDataToGridView();
                 ClearInput();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: " + ex.Message);
     }
 }
Beispiel #2
0
        public int UpdateObj(TurnCOMMng obj)
        {
            int kq = 0;

            try
            {
                string sql = "update TurnCOMMng set ComTypeId= " + obj.COMTypeId + ", Status = " + obj.Status + ", TimeAction='" + obj.TimeAction + "', Description=N'" + obj.Description + "', IsActive='" + obj.IsActive + "' where Id =" + obj.Id + " and IsDeleted=0";
                kq = dbclass.TruyVan_XuLy(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(kq);
        }
Beispiel #3
0
        public int AddObj(TurnCOMMng obj)
        {
            int kq = 0;

            try
            {
                string sql = "insert into TurnCOMMng(ComTypeId, Status, TimeAction, Description, IsActive) values(" + obj.COMTypeId + ", " + obj.Status + ", N'" + obj.TimeAction + "', '" + obj.Description + "', '" + obj.IsActive + "' )";
                kq = dbclass.TruyVan_XuLy(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(kq);
        }
Beispiel #4
0
        private TurnCOMMng BuildModel()
        {
            TurnCOMMng config = null;

            try
            {
                config             = new TurnCOMMng();
                config.Id          = configId;
                config.Description = txtDescription.Text;
                config.IsActive    = chkIsUse.Checked;
                config.COMTypeId   = cbbComport.SelectedIndex;
                config.Status      = cbbStatus.SelectedIndex;
                DateTime dateTimeAction = DateTime.Parse(tTimeAction.EditValue.ToString());
                TimeSpan timeAction     = dateTimeAction.TimeOfDay;
                config.TimeAction = new TimeSpan(timeAction.Hours, timeAction.Minutes, 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(config);
        }