private void btnAddVehicle_Click(object sender, EventArgs e)
 {
     try
     {
         var declarationInfo = new tblDeclaration();
         if (!string.IsNullOrEmpty(txtExportNumber.Text))
         {
             declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text);
         }
         declarationInfo.CreatedDate = CommonFactory.GetCurrentDate();
         declarationInfo.ProductName = txtExportProductName.Text;
         declarationInfo.ProductAmount = txtProductAmount.Text;
         // Add Mode
         if (_mode == 0)
         {
             var vehicle = new frmVehicle(0, _mainForm, ref _vehicleInfosTemp, declarationInfo, _userInfo);
             vehicle.Show(this);
         }
         else
         {
             declarationInfo = DeclarationFactory.GetByID(_declerationID);
             if (!string.IsNullOrEmpty(txtExportNumber.Text))
             {
                 declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text);
             }
             declarationInfo.CreatedDate = CommonFactory.GetCurrentDate();
             declarationInfo.ProductName = txtExportProductName.Text;
             declarationInfo.ProductAmount = txtProductAmount.Text;
             // Update Mode
             var vehicle = new frmVehicle(4, _mainForm, ref _vehicleInfosTemp, declarationInfo, _userInfo);
             vehicle.Show(this);
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
         if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
     }
 }
Exemple #2
0
        private void grdVehicle_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0 && grdVehicle.SelectedRows.Count == 1)
                {

                    var declarationInfo = new tblDeclaration();
                    if (!string.IsNullOrEmpty(txtExportNumber.Text))
                    {
                        declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text);
                    }
                    declarationInfo.CreatedDate = DateTime.Now;
                    declarationInfo.ProductName = txtExportProductName.Text;
                    declarationInfo.ProductAmount = txtExportProductAmount.Text;
                    declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked;

                    // Bind the gridview data to the vehicleInfo object, make sure, the vehicleInfotem dat is same as the gridview.
                    // Validate data of the gridview.
                    // Clear the tem data

                    //_vehicleInfosTemp.Clear();

                    _vehicleInfosTemp = (List<VehicleInfo>)grdVehicle.DataSource;
                    //VehicleInfo vehicleInfo;
                    //// Add data to the tem object
                    //for (int i = 0; i < grdVehicle.Rows.Count; i++)
                    //{
                    //    var row = grdVehicle.Rows[i];
                    //     vehicleInfo = new VehicleInfo();
                    //     if (row.Cells[ConstantInfo.TBL_VEHICLE_PLATE_NUMBER].Value != null)
                    //    {
                    //        vehicleInfo.PlateNumber = row.Cells[ConstantInfo.TBL_VEHICLE_PLATE_NUMBER].Value.ToString();
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_DRIVER_NAME].Value != null)
                    //    {
                    //        vehicleInfo.DriverName = row.Cells[ConstantInfo.TBL_VEHICLE_DRIVER_NAME].Value.ToString();
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_STATUS].Value != null)
                    //    {
                    //        vehicleInfo.Status = row.Cells[ConstantInfo.TBL_VEHICLE_STATUS].Value.ToString();
                    //    }
                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_NOTE].Value != null)
                    //    {
                    //        vehicleInfo.Note = row.Cells[ConstantInfo.TBL_VEHICLE_NOTE].Value.ToString();
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_EXPORT_HOUR].Value != null)
                    //    {
                    //        vehicleInfo.ExportHour = row.Cells[ConstantInfo.TBL_VEHICLE_EXPORT_HOUR].Value.ToString();
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_IS_EXPORT].Value != null)
                    //        vehicleInfo.IsExport = Convert.ToBoolean(row.Cells[ConstantInfo.TBL_VEHICLE_IS_EXPORT].Value.ToString());{
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_EXPORT_DATE].Value != null)
                    //    {
                    //        vehicleInfo.ExportDate =
                    //        Convert.ToDateTime(row.Cells[ConstantInfo.TBL_VEHICLE_EXPORT_DATE].Value.ToString());
                    //    }
                    //    if ((row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_DATE].Value != null))
                    //    {
                    //        vehicleInfo.ImportDate = Convert.ToDateTime(row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_DATE].Value.ToString());
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_HOUR].Value != null)
                    //    {
                    //        vehicleInfo.ImportHour = row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_HOUR].Value.ToString();
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_IS_IMPORT].Value != null)
                    //    {
                    //        vehicleInfo.IsImport = Convert.ToBoolean(row.Cells[ConstantInfo.TBL_VEHICLE_IS_IMPORT].Value.ToString());
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_VEHICLE_ID].Value != null)
                    //    {
                    //        vehicleInfo.VehicleID = Convert.ToInt32(row.Cells[ConstantInfo.TBL_VEHICLE_VEHICLE_ID].Value.ToString());
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_NUMBER_OF_CONTAINER].Value != null)
                    //    {
                    //        vehicleInfo.NumberOfContainer = Convert.ToInt32(row.Cells[ConstantInfo.TBL_VEHICLE_NUMBER_OF_CONTAINER].Value.ToString());
                    //    }

                    //    if (row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_HOUR].Value != null )
                    //    {
                    //        vehicleInfo.ImportHour = row.Cells[ConstantInfo.TBL_VEHICLE_IMPORT_HOUR].Value.ToString();
                    //    }

                    //    // If it is new mode, use Count as the flash, it store item count
                    //    if (this._mode == 0)
                    //    {
                    //        if (row.Cells["Count"].Value !=  null)
                    //        {
                    //            vehicleInfo.Count = Convert.ToInt32(row.Cells["Count"].Value);
                    //        }

                    //    }
                    //    _vehicleInfosTemp.Add(vehicleInfo);
                    //}

                    // New mode
                    if (this._mode == 0)
                    {
                        var vehicle = new frmVehicle(1, this, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["Count"].Value), declarationInfo, _userInfo);
                        vehicle.MdiParent = this.ParentForm;
                        vehicle.Show();
                    }
                    else if (this._mode == 1) // Update Mode
                    {
                        var vehicle = new frmVehicle(2, this, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["Count"].Value), declarationInfo, _userInfo);
                        vehicle.MdiParent = this.ParentForm;
                        vehicle.Show();
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
            }
        }
Exemple #3
0
 private void btnUpdateVehicle_Click(object sender, EventArgs e)
 {
     try
     {
         var declarationInfo = new tblDeclaration();
         if (!string.IsNullOrEmpty(txtExportNumber.Text))
         {
             declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text);
         }
         declarationInfo.CreatedDate = DateTime.Now;
         declarationInfo.ProductName = txtExportProductName.Text;
         declarationInfo.ProductAmount = txtExportProductAmount.Text;
         declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked;
         // New mode
         if (grdVehicle.SelectedRows.Count == 1 && this._mode == 0)
         {
             var vehicle = new frmVehicle(1, this, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.SelectedRows[0].Cells["Count"].Value), declarationInfo, _userInfo);
             vehicle.MdiParent = this.ParentForm;
             vehicle.Show();
         }
         else if (grdVehicle.SelectedRows.Count == 1 && this._mode == 1) // Update Mode
         {
             var vehicle = new frmVehicle(2, this, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.SelectedRows[0].Cells["Count"].Value), declarationInfo, _userInfo);
             vehicle.MdiParent = this.ParentForm;
             vehicle.Show();
         }
         else
         {
             MessageBox.Show("Bạn cần chọn 1 phương tiện cần cập nhật.");
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.ToString());
     }
 }
Exemple #4
0
 private void btnAddVehicle_Click(object sender, EventArgs e)
 {
     try
     {
         var declarationInfo = new tblDeclaration();
         if (!string.IsNullOrEmpty(txtExportNumber.Text))
         {
             declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text);
         }
         declarationInfo.CreatedDate = DateTime.Now;
         declarationInfo.ProductName = txtExportProductName.Text;
         declarationInfo.ProductAmount = txtExportProductAmount.Text;
         declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked;
         // Add Mode
         if (_mode == 0)
         {
             var vehicle = new frmVehicle(0, this, ref _vehicleInfosTemp, declarationInfo, _userInfo);
             vehicle.MdiParent = this.ParentForm;
             vehicle.Show();
         }
         else
         {
             declarationInfo = DeclarationFactory.SelectByID(_declerationID);
             if (!string.IsNullOrEmpty(txtExportNumber.Text))
             {
                 declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text);
             }
             declarationInfo.CreatedDate = DateTime.Now;
             declarationInfo.ProductName = txtExportProductName.Text;
             declarationInfo.ProductAmount = txtExportProductAmount.Text;
             declarationInfo.HasDeclaration = cbExportHasDeclaration.Checked;
             // Update Mode
             var vehicle = new frmVehicle(4, this, ref _vehicleInfosTemp, declarationInfo, _userInfo);
             vehicle.MdiParent = this.ParentForm;
             vehicle.Show();
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.ToString());
     }
 }
 private void btnUpdateVehicle_Click(object sender, EventArgs e)
 {
     try
     {
         if (grdVehicle.SelectedRows.Count == 1)
         {
             var vehicle = new frmVehicle(3, Convert.ToInt64(grdVehicle.SelectedRows[0].Cells["VehicleID"].Value), _userInfo, _mainForm, this);
             vehicle.MdiParent = this.ParentForm;
             vehicle.Show();
         }
         else
         {
             MessageBox.Show("Bạn cần chọn 1 phương tiện cần cập nhật.");
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
         if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
     }
 }
 private void grdVehicle_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (_userInfo.UserPermission.Contains(ConstantInfo.PERMISSON_CAP_NHAT_PHUONG_TIEN) || _userInfo.UserPermission.Contains(ConstantInfo.PERMISSON_XOA_PHUONG_TIEN) || _userInfo.UserPermission.Contains(ConstantInfo.PERMISSON_XAC_NHAN_NHAP_CANH) || _userInfo.UserPermission.Contains(ConstantInfo.PERMISSON_XAC_NHAN_XUAT_CANH))
     {
         try
         {
             if (e.RowIndex >= 0 && grdVehicle.SelectedRows.Count == 1) // Only select one row
             {
                 var vehicle = new frmVehicle(3, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["VehicleID"].Value), _userInfo, _mainForm, this);
                 vehicle.Show(this);
             }
         }
         catch (Exception ex)
         {
             logger.Error(ex.ToString());
             if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
         }
     }
 }
        //private void btnReset_Click(object sender, EventArgs e)
        //{
        //    try
        //    {
        //      txtExportNumber.Text = "";
        //      txtExportProductName.Text = "";
        //      txtExportCompanyName.Text = "";
        //      txtExportProductAmount.Text = "";
        //      txtExportUnit.Text = "";
        //      txtTypeExport.Text = "";
        //      txtExportCompanyCode.Text = "";
        //      txtExportCompanyCode.Text = "";
        //      dtpExportRegisterDate.Value = DateTime.Now;

        //      grdVehicle.Rows.Clear();
        //    }
        //    catch (Exception ex)
        //    {
        //        logger.Error(ex.ToString());
        //        if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
        //    }
        //}

        private void btnUpdateVehicle_Click(object sender, EventArgs e)
        {
            try
            {
                var declarationInfo = new tblDeclaration();
                if (!string.IsNullOrEmpty(txtExportNumber.Text))
                {
                    declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text);
                }
                declarationInfo.CreatedDate = CommonFactory.GetCurrentDate();
                declarationInfo.ProductName = txtExportProductName.Text;
                declarationInfo.ProductAmount = txtProductAmount.Text;
                // New mode
                if (grdVehicle.SelectedRows.Count == 1 && this._mode == 0)
                {
                    var vehicle = new frmVehicle(1, _mainForm, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.SelectedRows[0].Cells["Count"].Value), declarationInfo, _userInfo, _declerationType);
                    vehicle.Show(this);
                }
                else if (grdVehicle.SelectedRows.Count == 1 && this._mode == 1) // Update Mode
                {
                    var vehicle = new frmVehicle(2, _mainForm, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.SelectedRows[0].Cells["Count"].Value), declarationInfo, _userInfo, _declerationType);
                    vehicle.Show(this);
                }
                else
                {
                    MessageBox.Show("Bạn cần chọn 1 phương tiện cần cập nhật.");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
            }
        }
        private void grdVehicle_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (_userInfo.UserPermission.Contains(ConstantInfo.PERMISSON_CAP_NHAT_PHUONG_TIEN))
            {
                try
                {
                    if (e.RowIndex >= 0 && grdVehicle.SelectedRows.Count == 1)
                    {

                        var declarationInfo = new tblDeclaration();
                        if (!string.IsNullOrEmpty(txtExportNumber.Text))
                        {
                            declarationInfo.Number = Convert.ToInt32(txtExportNumber.Text);
                        }
                        declarationInfo.CreatedDate = CommonFactory.GetCurrentDate();
                        declarationInfo.ProductName = txtExportProductName.Text;
                        declarationInfo.ProductAmount = txtProductAmount.Text;

                        // Bind the gridview data to the vehicleInfo object, make sure, the vehicleInfotem dat is same as the gridview.
                        // Validate data of the gridview.
                        // Clear the tem data

                        //_vehicleInfosTemp.Clear();

                        _vehicleInfosTemp = (List<ViewAllVehicleHasGood>)grdVehicle.DataSource;


                        // New mode
                        if (this._mode == 0)
                        {
                            var vehicle = new frmVehicle(1, _mainForm, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["Count"].Value), declarationInfo, _userInfo, _declerationType);
                            vehicle.Show(this);
                        }
                        else if (this._mode == 1) // Update Mode
                        {
                            var vehicle = new frmVehicle(2, _mainForm, ref _vehicleInfosTemp, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["Count"].Value), declarationInfo, _userInfo, _declerationType);
                            vehicle.Show(this);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.ToString());
                    if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
                }
            }
        }
 private void grdVehicle_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         if (e.RowIndex >= 0 && grdVehicle.SelectedRows.Count == 1) // Only select one row
         {
             var vehicle = new frmVehicle(3, Convert.ToInt32(grdVehicle.Rows[e.RowIndex].Cells["VehicleID"].Value), _userInfo);
             vehicle.MdiParent = this.ParentForm;
             vehicle.Show();
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString());
         if (GlobalInfo.IsDebug) MessageBox.Show(ex.ToString());
     }
 }