コード例 #1
0
        public FrmAddVehicleFeeSetting(UserInfo userInfo, int type, FrmVehicleFeeSetting mainForm, tblVehicleFeeSetting vehicleFee)
        {
            //type =0: them moi
            //type=1: cap nhat
            InitializeComponent();
            _userInfo = userInfo;
            _type = type;
            _mainForm = mainForm;
            _vehicleFee = vehicleFee;

        }
コード例 #2
0
 public static int Insert(tblVehicleFeeSetting vehicleFee)
 {
     dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     _db.Connection.Open();
     vehicleFee.CreatedDate = CommonFactory.GetCurrentDate();
     vehicleFee.UpdatedDate = CommonFactory.GetCurrentDate();
     _db.AddTotblVehicleFeeSettings(vehicleFee);
     try
     {
         if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open();
         return _db.SaveChanges();
     }
     catch (Exception ex)
     {
         return 0;
     }
     finally
     {
         _db.Connection.Close();
     }
 }
コード例 #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                tblVehicleFeeSetting vehicleFee = new tblVehicleFeeSetting();
                vehicleFee.VehicleTypeId = int.Parse(cbVehicleType.SelectedValue.ToString());
                vehicleFee.GoodsTypeId = int.Parse(cbGoodType.SelectedValue.ToString());
                vehicleFee.Fee = long.Parse(txtFee.Text.Trim()) * 1000;
                vehicleFee.Description = txtDescription.Text.Trim();
                vehicleFee.CreatedUser = _userInfo.UserID;
                vehicleFee.UpdatedUser = _userInfo.UserID;

                if (VehicleFeeSettingFactory.Insert(vehicleFee) > 0)
                {
                    MessageBox.Show("Thêm mới biểu phí thành công", "Thêm thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _mainForm.bindListVehicleFee();
                    resetForm();

                }
            }
        }
コード例 #4
0
 public static int Delete (tblVehicleFeeSetting vehicleFee)
 {
     var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     _db.Connection.Open();
     var _vehicleFee = _db.tblVehicleFeeSettings.Where(g => g.VehicleTypeId == vehicleFee.VehicleTypeId && g.GoodsTypeId == vehicleFee.GoodsTypeId).FirstOrDefault();
     if (vehicleFee != null)
     {
         try
         {
             if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open();
             _db.DeleteObject(_vehicleFee);
             return _db.SaveChanges();
         }
         catch (Exception ex)
         {
             return 0;
         }
         finally
         {
             _db.Connection.Close();
         }
     }
     return 0;
 }