Пример #1
0
        public static int Update(tblGate gateObj)
        {
            dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
            _db.Connection.Open();

            tblGate originGate = _db.tblGates.Where(g => g.GateCode == gateObj.GateCode).FirstOrDefault();

            if (originGate == null)
            {
                return -1;
            }

            originGate.GateName = gateObj.GateName;
            originGate.Description = gateObj.Description;
            originGate.ModifiedBy = gateObj.ModifiedBy;
            originGate.ModifiedDate = CommonFactory.GetCurrentDate();

            try
            {
                return _db.SaveChanges();
            }
            catch (Exception ex)
            {
                return -1;
            }
            finally
            {
                _db.Connection.Close();
            }
        }
Пример #2
0
 public static int Insert(tblGate gate)
 {
     dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     _db.Connection.Open();
     gate.CreatedDate = CommonFactory.GetCurrentDate();
     gate.ModifiedDate = CommonFactory.GetCurrentDate();
     _db.AddTotblGates(gate);
     try
     {
         if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open();
         return _db.SaveChanges();
     }
     catch (Exception ex)
     {
         return -1;
     }
     finally
     {
         _db.Connection.Close();
     }
 }
Пример #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (_mode == 1)
            {
                if (validate())
                {
                    tblGate gate = new tblGate();
                    gate.GateCode = txtGateCode.Text.Trim();
                    gate.GateName = txtGateName.Text.Trim();
                    gate.Description = txtDescription.Text.Trim();
                    gate.ModifiedBy = _userInfo.UserID;
                    if (GateFactory.Update(gate) > 0)
                    {
                        try
                        {
                            _frmListGate.search();
                        }
                        catch (Exception ex)
                        {
                            //do nothing
                        }
                        MessageBox.Show("Cập nhật cửa khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    }
                    else
                    {
                        MessageBox.Show("Cập nhật cửa khẩu không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    }
                }
            }
        }