public  static int Insert(tblVehicleCheck tblVehicleCheck)
 {
     var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
     tblVehicleCheck.CreatedDate = CommonFactory.GetCurrentDate();
     db.AddTotblVehicleChecks(tblVehicleCheck);
     int re = db.SaveChanges();
     db.Connection.Close();
     return re;
 }
 public static int Update(tblVehicleCheck vehicleCheck)
 {
     var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));            
     // Get orgin object
     var objOrginVehicleCheck = db.tblVehicleChecks.Where(g => g.VehicleCheckID == vehicleCheck.VehicleCheckID).FirstOrDefault();
     db.Attach(objOrginVehicleCheck);
     db.ApplyPropertyChanges("tblVehicleChecks", vehicleCheck);
     int re = db.SaveChanges();
     db.Connection.Close();
     return re;        
 }
Ejemplo n.º 3
0
        private void btnAddVehicle_Click(object sender, EventArgs e)
        {
            try
            {
                // Get check information
                var check = CheckFactory.SelectByID(_checkID);

                var vehicleCheck = new tblVehicleCheck();
                vehicleCheck.VehicleID = _vehicleID;
                vehicleCheck.RecievedBy = _userInfo.UserID;
                vehicleCheck.InputBy = _userInfo.UserID;
                vehicleCheck.Result = txtResult.Text;
                if (check != null)
                {
                    vehicleCheck.CheckFrom = check.CheckFrom;
                    vehicleCheck.CheckTo = check.CheckTo;
                    vehicleCheck.CheckCode = check.CheckCode;
                }
                if (_checkType == VehicleCheckFactory.CHECK_TYPE_EXPORT)
                {
                    vehicleCheck.IsExportChecked = true;
                }
                if (_checkType == VehicleCheckFactory.CHECK_TYPE_IMPORT)
                {
                    vehicleCheck.IsImportChecked = true;
                }
                if (_checkType == VehicleCheckFactory.CHECK_TYPE_IMPORT_LOCAL)
                {
                    vehicleCheck.IsLocalImportChecked = true;
                }

                VehicleCheckFactory.Insert(vehicleCheck);
                MessageBox.Show("Nhập thông tin xong");
                this.Owner.Close();
                this.Close();
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 4
0
    private void btnConfirm_Click(object sender, EventArgs e)
    {
      try
      {
        // Get check information
        var check = CheckFactory.SelectByID(_checkID);
        var vehicleCheck = VehicleCheckFactory.GetExistingVehicleHasChecked(_vehicleID).FirstOrDefault();
        if (vehicleCheck != null)
        {
          if (_checkType == VehicleCheckFactory.CHECK_TYPE_EXPORT)
          {
            vehicleCheck.IsExportChecked = true;
          }
          if (_checkType == VehicleCheckFactory.CHECK_TYPE_IMPORT)
          {
            vehicleCheck.IsImportChecked = true;
          }
          if (_checkType == VehicleCheckFactory.CHECK_TYPE_IMPORT_LOCAL)
          {
            vehicleCheck.IsLocalImportChecked = true;
          }
          vehicleCheck.InputBy = _userInfo.UserID;

          if (check != null)
          {
            vehicleCheck.CheckFrom = check.CheckFrom;
            vehicleCheck.CheckTo = check.CheckTo;
          }

          

          //update
          VehicleCheckFactory.Update(vehicleCheck);
        }
        else
        {

          vehicleCheck = new tblVehicleCheck();
          vehicleCheck.VehicleID = _vehicleID;
          vehicleCheck.InputBy = _userInfo.UserID;

          if (check != null)
          {
            vehicleCheck.CheckFrom = check.CheckFrom;
            vehicleCheck.CheckTo = check.CheckTo;
          }

          if (_checkType == VehicleCheckFactory.CHECK_TYPE_EXPORT)
          {
            vehicleCheck.IsExportChecked = true;
          }
          if (_checkType == VehicleCheckFactory.CHECK_TYPE_IMPORT)
          {
            vehicleCheck.IsImportChecked = true;
          }
          if (_checkType == VehicleCheckFactory.CHECK_TYPE_IMPORT_LOCAL)
          {
            vehicleCheck.IsLocalImportChecked = true;
          }

          // Insert new 
          VehicleCheckFactory.Insert(vehicleCheck);
        }
        MessageBox.Show("Xác nhận cảnh báo thành công");
        this.Close();
      }
      catch (Exception ex)
      {
        logger.Error(ex.ToString());
        if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
      }
    }