コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!checkValid())
                {
                    return;
                }
                ModuleErrorTypeModel model;
                if (_isAdd)
                {
                    model = new ModuleErrorTypeModel();
                }
                else
                {
                    model = (ModuleErrorTypeModel)ModuleErrorTypeBO.Instance.FindByPK(_id);
                }

                //model.Type = cboType.SelectedIndex;
                model.Type    = 0;
                model.Name    = txtName.Text.Trim();
                model.GroupID = (int)cboGroup.SelectedValue;

                if (_isAdd)
                {
                    pt.Insert(model);
                }
                else
                {
                    pt.Update(model);
                }

                pt.CommitTransaction();

                if (model.GroupID == 0)
                {
                    loadGroup();
                }

                loadTree();

                SetInterface(false);
                ClearInterface();

                _isSaved = true;
            }
            catch (Exception ex)
            {
                TextUtils.ShowError("Lưu trữ không thành công!", ex);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #2
0
        private void btnSaveN_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (checkValidN())
                {
                    MaterialParametersModel model = new MaterialParametersModel();

                    if (isAddN)
                    {
                        model.CreatedDate = TextUtils.GetSystemDate();
                        model.CreatedBy   = Global.AppUserName;
                        model.UpdatedDate = model.CreatedDate;
                        model.UpdatedBy   = Global.AppUserName;
                    }
                    else
                    {
                        int ID = Convert.ToInt32(grvDataN.GetFocusedRowCellValue(colID).ToString());
                        model             = (MaterialParametersModel)MaterialParametersBO.Instance.FindByPK(ID);
                        model.UpdatedDate = model.CreatedDate;
                        model.UpdatedBy   = Global.AppUserName;
                    }

                    model.Name            = txtNameN.Text;
                    model.MaterialGroupID = TextUtils.ToInt(cboMaterialGroupN.EditValue);

                    if (isAddN)
                    {
                        DataTable dt = TextUtils.Select("SELECT isnull(MAX(STT),0) FROM MaterialParameters with(nolock) where MaterialParameters.MaterialGroupID = " + model.MaterialGroupID);
                        model.STT = TextUtils.ToInt(dt.Rows[0][0].ToString()) + 1;
                        pt.Insert(model);
                    }
                    else
                    {
                        pt.Update(model);
                    }

                    pt.CommitTransaction();

                    loadGridParasN();
                    SetInterfaceN(false);
                    cboMaterialGroupN.Enabled = true;
                    ClearInterfaceN();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #3
0
        void save()
        {
            mnuMenu.Focus();
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                PartBorrow.DateBorrow         = (DateTime?)dtpDateBorrow.EditValue;
                PartBorrow.DateReturn         = (DateTime?)dtpDateReturn.EditValue;
                PartBorrow.DateReturnExpected = (DateTime?)dtpDateReturnExpected.EditValue;

                PartBorrow.Price       = TextUtils.ToDecimal(txtPrice.EditValue);
                PartBorrow.Qty         = TextUtils.ToDecimal(txtQty.EditValue);
                PartBorrow.QtyBorrow   = TextUtils.ToDecimal(txtQtyBorrow.EditValue);
                PartBorrow.QtyReturn   = TextUtils.ToDecimal(txtQtyReturn.EditValue);
                PartBorrow.Total       = TextUtils.ToDecimal(txtTotal.EditValue);
                PartBorrow.Description = txtDescription.Text.Trim();

                PartBorrow.PartsId = TextUtils.ToString(cboPart.EditValue);
                PartBorrow.Unit    = TextUtils.ToString(cboUnit.SelectedValue);
                PartBorrow.UserId  = TextUtils.ToString(cboUser.EditValue);

                if (PartBorrow.ID == 0)
                {
                    PartBorrow.ID = (long)pt.Insert(PartBorrow);
                }
                else
                {
                    pt.Update(PartBorrow);
                }

                pt.CommitTransaction();

                _isSaved = true;
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #4
0
ファイル: frmCoCauMau.cs プロジェクト: B06-0253/NVTHAO
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                if (CoCau.ID == 0)
                {
                    CoCau = new CoCauMauModel();
                }

                CoCau.Name         = txtName.Text.Trim().ToUpper();
                CoCau.Code         = txtCode.Text.Trim().ToUpper();
                CoCau.CoCauGroupID = TextUtils.ToInt(cboGroup.EditValue);
                //CoCau.Note = txtDescription.Text.Trim();
                CoCau.Description    = txtDescription.Text.Trim();
                CoCau.Specifications = txtTSKT.Text.Trim();
                CoCau.ImagePath      = pictureBox1.ImageLocation;

                if (CoCau.ID == 0)
                {
                    CoCau.ID = (int)pt.Insert(CoCau);
                }
                else
                {
                    pt.Update(CoCau);
                }

                pt.CommitTransaction();

                _isSaved = true;
                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #5
0
ファイル: frmCreate.cs プロジェクト: mrgrey88/QLTK
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                Model.Name        = txtName.Text.Trim();
                Model.ParentID    = TextUtils.ToInt(cboParent.SelectedValue);
                Model.Type        = Type;
                Model.Description = txtDes.Text.Trim();
                Model.Extension   = txtExtension.Text.Trim();
                Model.Contain     = txtContain.Text.Trim();

                if (ParentID == 0)
                {
                    Model.ParentPath = DPath;
                    Model.Path       = Path.Combine(DPath, txtName.Text.Trim());
                }
                else
                {
                    Model.ParentPath = ((DesignStructureModel)DesignStructureBO.Instance.FindByPK(ParentID)).Path;
                    Model.Path       = Path.Combine(Model.ParentPath, txtName.Text.Trim());
                }

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);
                }

                CurentNode = Model.ID;
                pt.CommitTransaction();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkValid())
                {
                    ProcessTransaction pt = new ProcessTransaction();
                    pt.OpenConnection();
                    pt.BeginTransaction();
                    if (!isAdd)
                    {
                        _model = (ConfigSystemModel)ConfigSystemBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)));
                    }

                    _model.KeyName     = txtKey.Text.Trim();
                    _model.KeyValue    = txtDuongDan.Text.Trim();
                    _model.Description = txtMoTa.Text.Trim();

                    if (isAdd)
                    {
                        _model.CreatedDate = TextUtils.GetSystemDate();
                        _model.CreatedBy   = Global.AppUserName;
                        _model.UpdatedDate = _model.CreatedDate;
                        _model.UpdatedBy   = Global.AppUserName;
                        _model.ID          = (int)pt.Insert(_model);
                    }
                    else
                    {
                        _model.UpdatedDate = TextUtils.GetSystemDate();
                        _model.UpdatedBy   = Global.AppUserName;
                        pt.Update(_model);
                    }

                    pt.CommitTransaction();
                    pt.CloseConnection();
                    LoadData();
                    if (isAdd)
                    {
                        MessageBox.Show("Tạo mới thành công!");
                    }
                    else
                    {
                        MessageBox.Show("Cập nhật thành công!");
                    }
                    SetInterface(false);
                    ClearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #7
0
ファイル: frmWorkView.cs プロジェクト: B06-0253/NVTHAO
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                Model.Code         = txtCode.Text.Trim();
                Model.Name         = txtName.Text.Trim();
                Model.TotalTime    = (double)txtTotalTime.Value;
                Model.ProductID    = TextUtils.ToInt(leProducts.EditValue);
                Model.WorkStatusID = cboStatus.SelectedIndex;
                Model.WorkTypeID   = cboWorkType.SelectedIndex;
                Model.Type         = cboType.SelectedIndex;
                Model.TotalScore   = TextUtils.ToDouble(txtTotalScore.Value);
                Model.Priority     = TextUtils.ToInt(txtPriority.Value);
                Model.Description  = txtDescription.Text.Trim();

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);
                }

                pt.CommitTransaction();

                MessageBox.Show("Lưu trữ thành công!", "Thông báo");
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            { pt.CloseConnection(); }
        }
コード例 #8
0
ファイル: frmCostDetail.cs プロジェクト: B06-0253/NVTHAO
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (checkValid())
                {
                    CostDetailModel dModel;
                    if (_isAdd)
                    {
                        dModel = new CostDetailModel();
                    }
                    else
                    {
                        int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                        dModel = (CostDetailModel)CostDetailBO.Instance.FindByPK(ID);
                    }

                    dModel.Code         = txtCode.Text.Trim();
                    dModel.Name         = txtName.Text.Trim();
                    dModel.Description  = txtDescription.Text.Trim();
                    dModel.Type         = cboCostType.SelectedIndex;
                    dModel.IsFix        = chkIsFix.Checked ? 1 : 0;
                    dModel.DepartmentID = TextUtils.ToInt(cboDepartment.EditValue);

                    if (_isAdd)
                    {
                        pt.Insert(dModel);
                    }
                    else
                    {
                        pt.Update(dModel);
                    }
                    pt.CommitTransaction();
                    loadData();
                    SetInterface(false);
                    ClearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #9
0
ファイル: frmPermission.cs プロジェクト: Dung12345678/Dao
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                if (Model == null)
                {
                    Model = new FormAndFunctionModel();
                }

                Model.Name = txtName.Text.Trim();
                Model.Code = txtCode.Text.Trim();
                Model.FormAndFunctionGroupID = TextUtils.ToInt(leParentCat.EditValue);
                Model.IsHide = false;

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);
                }

                pt.CommitTransaction();

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                PayVouchersModel dModel;
                if (_isAdd)
                {
                    dModel = new PayVouchersModel();
                }
                else
                {
                    int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                    dModel = (PayVouchersModel)PayVouchersBO.Instance.FindByPK(ID);
                }
                if (!checkValid(dModel))
                {
                    return;
                }

                dModel.Name = txtName.Text.Trim();
                dModel.Type = cboType.SelectedIndex;

                if (_isAdd)
                {
                    pt.Insert(dModel);
                }
                else
                {
                    pt.Update(dModel);
                }
                pt.CommitTransaction();
                loadData();
                SetInterface(false);
                ClearInterface();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                Model.Name         = txtName.Text.Trim();
                Model.ParentID     = TextUtils.ToInt(cboParent.SelectedValue);
                Model.DepartmentID = DepartmentID;
                Model.Description  = txtDes.Text.Trim();
                Model.FolderType   = cboFolderType.SelectedIndex;

                if (ParentID == 0)
                {
                    Model.ParentPath = DPath;
                    Model.Path       = Path.Combine(DPath, txtName.Text.Trim());
                }
                else
                {
                    Model.ParentPath = ((PBDLStructureModel)PBDLStructureBO.Instance.FindByPK(ParentID)).Path;
                    Model.Path       = Path.Combine(Model.ParentPath, txtName.Text.Trim());
                }

                if (Model.ID == 0)
                {
                    Model.ID = (int)pt.Insert(Model);
                }
                else
                {
                    pt.Update(Model);
                }

                CurentNode = Model.ID;
                pt.CommitTransaction();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #12
0
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                MisMatch.StatusTK = cboStatus.SelectedIndex;

                if (MisMatch.ID == 0)
                {
                    MisMatch.ID = (int)pt.Insert(MisMatch);
                }
                else
                {
                    pt.Update(MisMatch);
                }

                pt.CommitTransaction();
                _isSaved = true;

                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #13
0
        private void btnChooseFile_Click(object sender, EventArgs e)
        {
            frmDatasheet frm = new frmDatasheet();

            frm.ChooseFile = true;
            frm.CustomerID = Material.CustomerID;
            frm.Text      += ": " + Material.Code + " - " + Material.Name;
            bool added = false;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                foreach (int item in frm.ListMaterialFileID)
                {
                    ProcessTransaction pt = new ProcessTransaction();
                    pt.OpenConnection();
                    pt.BeginTransaction();
                    try
                    {
                        MaterialFileLinkModel model = new MaterialFileLinkModel();
                        model.MaterialID     = Material.ID;
                        model.MaterialFileID = item;
                        pt.Insert(model);

                        added = true;

                        if (added)
                        {
                            //MaterialModel material = (MaterialModel)MaterialBO.Instance.FindByPK(Material.ID);
                            Material.FileDatasheet = 1;
                            pt.Update(Material);
                        }
                        pt.CommitTransaction();
                    }
                    catch (Exception)
                    {
                    }
                    finally
                    {
                        pt.CloseConnection();
                    }
                }

                loadDatasheet();
            }
        }
コード例 #14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                if (Model == null)
                {
                    Model = new BaiThucHanhGroupModel();
                }
                Model.Name        = txtName.Text.Trim().ToUpper();
                Model.Code        = txtCode.Text.Trim().ToUpper();
                Model.Description = txtDescription.Text.Trim();
                Model.ParentID    = TextUtils.ToInt(leParentCat.EditValue);
                if (Model.ID == 0)
                {
                    Model.ID = (int)pt.Insert(Model);
                }
                else
                {
                    pt.Update(Model);
                }

                pt.CommitTransaction();

                CurentNode        = Model.ID;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #15
0
ファイル: frmProductPrice.cs プロジェクト: B06-0253/NVTHAO
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                Product.CostGroupID = TextUtils.ToInt(cboCostGroup.EditValue);

                pt.Update(Product);

                pt.CommitTransaction();
                _isSaved = true;

                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
            if (_isSaved && close)
            {
                this.Close();
            }
        }
コード例 #16
0
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                grvFile.FocusedRowHandle = -1;

                #region Save Solution
                Solution.Name = txtName.Text.Trim().ToUpper();
                Solution.Code = txtCode.Text.Trim();
                Solution.RequireSolutionID = TextUtils.ToInt64(cboRequire.EditValue);

                Solution.Description          = txtDescription.Text;
                Solution.WorkDescription      = txtWorkDescription.Text;
                Solution.Version              = 1;
                Solution.Status               = cboStatus.SelectedIndex;
                Solution.NguoiPhuTrach        = TextUtils.ToInt(cboNguoiPhuTrach.EditValue);
                Solution.TotalCost            = TextUtils.ToDecimal(txtTotalCost.EditValue);
                Solution.Area                 = TextUtils.ToInt(cboArea.EditValue);
                Solution.SolutionTechnologyID = TextUtils.ToInt(cboTechnology.EditValue);
                Solution.StopReason           = txtReasonStop.Text;
                Solution.IsDeleted            = false;

                Solution.UpdatedDate = TextUtils.GetSystemDate();
                Solution.UpdatedBy   = Global.AppUserName;

                if (Solution.ID <= 0)
                {
                    Solution.CreatedDate = TextUtils.GetSystemDate();
                    Solution.CreatedBy   = Global.AppUserName;
                    Solution.ID          = (long)pt.Insert(Solution);
                }
                else
                {
                    pt.Update(Solution);
                }
                #endregion

                #region Save File
                DataRow[] drs = _dtFile.Select("ID = 0 or ID is null");
                if (drs.Length > 0)
                {
                    DocUtils.InitFTPTK();

                    using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang update tên cho file..."))
                    {
                        for (int i = 0; i < grvFile.RowCount; i++)
                        {
                            long id = TextUtils.ToInt64(grvFile.GetRowCellValue(i, colFileID));
                            if (id > 0)
                            {
                                SolutionFileModel fileModel = (SolutionFileModel)SolutionFileBO.Instance.FindByPK(id);
                                fileModel.Description = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileDescription));
                                pt.Update(fileModel);
                            }
                            else
                            {
                                string   name        = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileName));
                                string   extension   = Path.GetExtension(name);
                                decimal  length      = TextUtils.ToDecimal(grvFile.GetRowCellValue(i, colFileLenght));
                                string   description = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileDescription));
                                string   path        = "GiaiPhap/" + Solution.Code + "/" + name;
                                string   createdBy   = Global.AppUserName;
                                DateTime?createdDate = DateTime.Now;

                                string localPath = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileLocalPath));

                                if (!DocUtils.CheckExits("GiaiPhap/" + Solution.Code))
                                {
                                    DocUtils.MakeDir("GiaiPhap/" + Solution.Code);
                                }

                                SolutionFileModel fileModel = new SolutionFileModel();
                                fileModel.CreatedBy          = createdBy;
                                fileModel.CreatedDate        = createdDate;
                                fileModel.Description        = description;
                                fileModel.Extension          = extension;
                                fileModel.Length             = length;
                                fileModel.Name               = name;
                                fileModel.Path               = path;
                                fileModel.SolutionID         = Solution.ID;
                                fileModel.SolutionFileTypeID = TextUtils.ToInt(grvGroupFile.GetFocusedRowCellValue(colGFID));
                                pt.Insert(fileModel);

                                DocUtils.UploadFile(localPath, "GiaiPhap/" + Solution.Code);
                            }
                        }
                    }
                }
                #endregion

                #region Save DMVT
                for (int i = 0; i < grvVT.RowCount; i++)
                {
                    long id = TextUtils.ToInt64(grvVT.GetRowCellValue(i, colMaID));
                    SolutionItemModel item = new SolutionItemModel();
                    if (id > 0)
                    {
                        item = (SolutionItemModel)SolutionItemBO.Instance.FindByPK(id);
                    }

                    item.Code       = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaCode));
                    item.Name       = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaName));
                    item.Hang       = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaHang));
                    item.Qty        = TextUtils.ToDecimal(grvVT.GetRowCellValue(i, colMaQty));
                    item.Price      = TextUtils.ToDecimal(grvVT.GetRowCellValue(i, colMaPrice));
                    item.TotalPrice = TextUtils.ToDecimal(grvVT.GetRowCellValue(i, colMaTotalPrice));
                    item.QtyError   = TextUtils.ToInt(grvVT.GetRowCellValue(i, colMaError));
                    item.QtyKPH     = TextUtils.ToInt(grvVT.GetRowCellValue(i, colMaKPH));
                    item.QtyTon     = TextUtils.ToInt(grvVT.GetRowCellValue(i, colMaTonKho));

                    //item.Unit = TextUtils.ToString(grvVT.GetRowCellValue(i, colMau));
                    //item.Status = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaCode));
                    //item.Type = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaCode));

                    item.SolutionID = Solution.ID;
                    if (id > 0)
                    {
                        pt.Update(item);
                    }
                    else
                    {
                        pt.Insert(item);
                    }
                }
                #endregion

                pt.CommitTransaction();

                loadFile();
                loadDMVT();
                _isSaved = true;

                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #17
0
ファイル: frmProjectView.cs プロジェクト: B06-0253/NVTHAO
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                Model.ProjectCode      = txtProjectCode.Text.Trim();
                Model.ProjectName      = txtProjectName.Text.Trim();
                Model.ContractCode     = txtContractCode.Text.Trim();
                Model.ContractName     = txtContractName.Text.Trim();
                Model.Curator          = txtCurator.Text.Trim();
                Model.Reception        = txtReception.Text.Trim();
                Model.Requirement      = txtRequirement.Text.Trim();
                Model.Status           = cboStatus.SelectedIndex;
                Model.CustomerName     = txtCustomerName.Text.Trim();
                Model.LastCustomerName = txtLastCustomerName.Text.Trim();
                Model.Priority         = txtPriority.Text.Trim();
                Model.Description      = txtDescription.Text.Trim();

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);
                }

                if (_listProducts.Count > 0)
                {
                    foreach (ProductsModel item in _listProducts)
                    {
                        item.CreatedBy     = Global.AppUserName;
                        item.CreatedDate   = TextUtils.GetSystemDate();
                        item.UpdatedDate   = item.CreatedDate;
                        item.UpdatedBy     = Global.AppUserName;
                        item.ProjectInfoID = Model.ID;
                        pt.Insert(item);
                    }
                }
                //MessageBox.Show("Lưu trữ thành công!", "Thông báo");
                pt.CommitTransaction();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #18
0
ファイル: frmReportNotPay.cs プロジェクト: B06-0253/NVTHAO
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            decimal tm = 0;
            decimal ck = 0;

            PaymentTableModel PaymentTable = new PaymentTableModel();

            PaymentTable.IsDeleted = false;
            PaymentTable.Note      = "";
            PaymentTable.Number    = loadNumber();
            //PaymentTable.TotalTM = TextUtils.ToDecimal(colTM.SummaryItem.SummaryValue);
            //PaymentTable.TotalCK = TextUtils.ToDecimal(colCK.SummaryItem.SummaryValue);
            PaymentTable.UpdatedBy   = Global.AppUserName;
            PaymentTable.UpdatedDate = DateTime.Now;
            PaymentTable.CreatedBy   = Global.AppUserName;
            PaymentTable.CreatedDate = DateTime.Now;

            PaymentTable.ID = (long)pt.Insert(PaymentTable);

            grvData.FocusedRowHandle = -1;
            for (int i = 0; i < grvData.RowCount; i++)
            {
                if (i < 0)
                {
                    continue;
                }
                bool check = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colCheck));
                if (!check)
                {
                    continue;
                }

                long iD = TextUtils.ToInt64(grvData.GetRowCellValue(i, colID));
                PaymentTableItemModel model = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(iD);

                PaymentTableModel pay = (PaymentTableModel)PaymentTableBO.Instance.FindByPK(model.PaymentTableID);
                pay.TotalTM -= model.TotalCash;
                pay.TotalCK -= model.TotalCK;
                pt.Update(pay);

                model.PaymentTableID = PaymentTable.ID;
                pt.Update(model);

                tm += model.TotalCash;
                ck += model.TotalCK;
            }

            pt.CommitTransaction();

            PaymentTable.TotalTM = tm;
            PaymentTable.TotalCK = ck;

            PaymentTableItemBO.Instance.Update(PaymentTable);

            loadItems();
        }
コード例 #19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }
                grvData.FocusedRowHandle = -1;

                PaymentTable.IsDeleted   = false;
                PaymentTable.Note        = "";
                PaymentTable.Number      = txtNumber.Text.Trim();
                PaymentTable.TotalTM     = TextUtils.ToDecimal(colTM.SummaryItem.SummaryValue);
                PaymentTable.TotalCK     = TextUtils.ToDecimal(colCK.SummaryItem.SummaryValue);
                PaymentTable.UpdatedBy   = Global.AppUserName;
                PaymentTable.UpdatedDate = DateTime.Now;

                if (PaymentTable.ID == 0)
                {
                    PaymentTable.CreatedBy   = Global.AppUserName;
                    PaymentTable.CreatedDate = DateTime.Now;
                    PaymentTable.ID          = (long)pt.Insert(PaymentTable);
                }
                else
                {
                    pt.Update(PaymentTable);
                }

                for (int i = 0; i < grvData.RowCount; i++)
                {
                    string code = TextUtils.ToString(grvData.GetRowCellValue(i, colCode));
                    if (code == "")
                    {
                        continue;
                    }

                    long id = TextUtils.ToInt64(grvData.GetRowCellValue(i, colID));
                    PaymentTableItemModel item = new PaymentTableItemModel();
                    if (id > 0)
                    {
                        item = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(id);
                    }
                    item.Code         = code;
                    item.Content      = TextUtils.ToString(grvData.GetRowCellValue(i, colContent));
                    item.ContentCheck = TextUtils.ToString(grvData.GetRowCellValue(i, colContentCheck));
                    item.Target       = TextUtils.ToString(grvData.GetRowCellValue(i, colTarget));
                    item.Name         = TextUtils.ToString(grvData.GetRowCellValue(i, colName));
                    item.Note         = TextUtils.ToString(grvData.GetRowCellValue(i, colNote));

                    item.PaymentTableID = PaymentTable.ID;

                    item.IsCash = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsTM));

                    item.Total        = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTotal));
                    item.TotalTH      = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTotalTH));
                    item.DeliveryCost = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colDeliveryCost));
                    item.DiffCost     = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colDiffCost));

                    item.PercentPay = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colPercentPay));
                    item.TotalCash  = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTM));
                    item.TotalCK    = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colCK));

                    item.UserId = TextUtils.ToString(grvData.GetRowCellValue(i, colOrderUserId));

                    item.CompanyID    = TextUtils.ToInt(grvData.GetRowCellValue(i, colCompany));
                    item.DepartmentId = TextUtils.ToString(grvData.GetRowCellValue(i, colDepartment));
                    item.ProjectId    = TextUtils.ToString(grvData.GetRowCellValue(i, colProject));
                    item.CostID       = TextUtils.ToInt(grvData.GetRowCellValue(i, colCost));
                    item.CountProject = TextUtils.ToInt(grvData.GetRowCellValue(i, colCountProject));
                    item.VAT          = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colVAT));

                    item.ContractStatus = TextUtils.ToInt1(grvData.GetRowCellValue(i, colContractStatus));
                    item.InvoiceStatus  = TextUtils.ToInt1(grvData.GetRowCellValue(i, colInvoiceStatus));
                    item.IsPO           = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsPO));
                    item.IsCongNo       = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCongNo));
                    item.IsCuongVe      = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCuongVe));
                    item.IsGDD          = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsGĐĐ));
                    item.IsTTGH         = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsTTGH));
                    item.IsVV_DA_NCC    = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsVV_DA_NCC));

                    if (id > 0)
                    {
                        pt.Update(item);
                    }
                    else
                    {
                        pt.Insert(item);
                    }

                    ArrayList listOrder = OrdersBO.Instance.FindByAttribute("OrderCode", item.Code);
                    if (listOrder.Count > 0)
                    {
                        OrdersModel order = (OrdersModel)listOrder[0];
                        order.StatusTT = 2;
                        pt.UpdateQLSX(order);
                    }
                }

                pt.CommitTransaction();
                loadItems();
                _isSaved = true;
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #20
0
        void createProductVersion(ProductsModel product, string reason)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                #region Tạo phiên bản san phẩm
                ProductVersionModel versionModel = new ProductVersionModel();
                versionModel.ProductID = product.ID;
                versionModel.Reason    = reason;
                versionModel.Version   = product.Version + 1;
                versionModel.ID        = (int)pt.Insert(versionModel);
                #endregion

                #region Tạo phiên bản bài thực hành của sản phẩm
                ArrayList lisBaiThucHanh = ProductBaiThucHanhLinkBO.Instance.FindByAttribute("ProductID", product.ID);
                if (lisBaiThucHanh.Count > 0)
                {
                    foreach (var item in lisBaiThucHanh)
                    {
                        ProductBaiThucHanhLinkModel thisBTH = (ProductBaiThucHanhLinkModel)item;

                        ProductBaiThucHanhLinkVersionModel bthVersion = new ProductBaiThucHanhLinkVersionModel();
                        bthVersion.ProductVersionID = versionModel.ID;
                        bthVersion.BaiThucHanhID    = thisBTH.BaiThucHanhID;
                        bthVersion.ID = (int)pt.Insert(bthVersion);
                    }
                }
                #endregion

                #region Tạo các phiên bản module sản phẩm
                ArrayList lisModules = ProductModuleLinkBO.Instance.FindByAttribute("ProductID", product.ID);
                if (lisModules.Count > 0)
                {
                    foreach (var item in lisModules)
                    {
                        ProductModuleLinkModel thisModule = (ProductModuleLinkModel)item;

                        ProductModuleLinkVersionModel moduleVersion = new ProductModuleLinkVersionModel();
                        moduleVersion.ProductVersionID = versionModel.ID;
                        moduleVersion.Code             = thisModule.Code;
                        moduleVersion.CVersion         = thisModule.CVersion;
                        moduleVersion.Hang             = thisModule.Hang;
                        moduleVersion.Name             = thisModule.Name;
                        moduleVersion.Qty  = thisModule.Qty;
                        moduleVersion.Type = thisModule.Type;
                        moduleVersion.ID   = (int)pt.Insert(moduleVersion);
                    }
                }
                #endregion

                #region Tạo phiên bản các file
                List <string> listFilePath = new List <string>();
                ArrayList     listFiles    = ProductFileBO.Instance.FindByExpression(new Expression("ProductID", product.ID)
                                                                                     .And(new Expression("Version", product.Version)));

                string ftpFolderPath = "Product\\BaiThucHanh\\" + product.Code + "\\" + versionModel.Version;
                if (!DocUtils.CheckExits(Path.GetDirectoryName(ftpFolderPath)))
                {
                    DocUtils.MakeDir(Path.GetDirectoryName(ftpFolderPath));
                }
                foreach (var item in listFiles)
                {
                    ProductFileModel thisFile = (ProductFileModel)item;
                    string           path     = Path.GetTempPath();

                    DocUtils.DownloadFile(path, Path.GetFileName(thisFile.Path), thisFile.Path);

                    ProductFileModel file = new ProductFileModel();
                    file.ProductID = product.ID;
                    file.Name      = thisFile.Name;
                    file.Length    = thisFile.Length;
                    file.LocalPath = path + "\\" + Path.GetFileName(thisFile.Path);
                    file.Path      = ftpFolderPath + "\\" + file.Name;
                    file.Version   = versionModel.Version;

                    pt.Insert(file);

                    listFilePath.Add(path + "\\" + Path.GetFileName(thisFile.Path));
                }
                #endregion

                product.Version += 1;
                pt.Update(product);

                pt.CommitTransaction();

                MessageBox.Show("Tạo phiên bản bài thực hành thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);

                foreach (string filePath in listFilePath)
                {
                    if (!DocUtils.CheckExits(ftpFolderPath))
                    {
                        DocUtils.MakeDir(ftpFolderPath);
                    }
                    DocUtils.UploadFile(filePath, ftpFolderPath);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #21
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (checkValid())
                {
                    ModuleFilmModel dModel;
                    if (_isAdd)
                    {
                        dModel = new ModuleFilmModel();
                    }
                    else
                    {
                        int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                        dModel = (ModuleFilmModel)ModuleFilmBO.Instance.FindByPK(ID);
                    }

                    dModel.Code           = txtCode.Text.ToUpper().Trim();
                    dModel.LastDateChange = TextUtils.ToDate(deUpdatedDate.EditValue.ToString());
                    dModel.LastTimeChange = TextUtils.ToInt(txtTime.Text.Trim());
                    dModel.ModuleID       = ModuleID;

                    if (_isAdd)
                    {
                        pt.Insert(dModel);
                    }
                    else
                    {
                        pt.Update(dModel);

                        if (txtReason.Enabled)
                        {
                            ModuleFilmHistoryModel hModel = new ModuleFilmHistoryModel();
                            hModel.ModuleFilmID   = dModel.ID;
                            hModel.LastTimeChange = dModel.LastTimeChange;
                            hModel.LastDateChange = dModel.LastDateChange;
                            hModel.Reason         = txtReason.Text.Trim();
                            hModel.UpdatedDate    = TextUtils.GetSystemDate();
                            hModel.UpdatedBy      = Global.AppUserName;
                            hModel.Code           = dModel.Code;
                            pt.Insert(hModel);
                        }
                    }

                    pt.CommitTransaction();

                    LoadData();
                    setInterface(false);
                    clearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #22
0
ファイル: frmMisMatch.cs プロジェクト: B06-0253/NVTHAO
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            DocUtils.InitFTPTK();
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang up file lên server!"))
                {
                    foreach (string filePath in ofd.FileNames)
                    {
                        ProcessTransaction pt = new ProcessTransaction();
                        pt.OpenConnection();
                        pt.BeginTransaction();
                        try
                        {
                            MisMatchImageModel errorImageModel;
                            bool isAdd = true;
                            if (!MisMatchImageBO.Instance.CheckExist("FileName", Path.GetFileName(filePath)))
                            {
                                errorImageModel = new MisMatchImageModel();
                            }
                            else
                            {
                                errorImageModel = (MisMatchImageModel)MisMatchImageBO.Instance.FindByAttribute("FileName", Path.GetFileName(filePath))[0];
                                isAdd           = false;
                            }

                            FileInfo fInfo = new FileInfo(filePath);

                            string ftpFolderPath = "Modules\\KPHImage\\" + MisMatch.Code;

                            errorImageModel.CreatedDate = TextUtils.GetSystemDate();
                            errorImageModel.CreatedBy   = Global.LoginName;
                            errorImageModel.FileName    = Path.GetFileName(filePath);
                            errorImageModel.Size        = fInfo.Length;
                            errorImageModel.FilePath    = ftpFolderPath + "\\" + errorImageModel.FileName;
                            errorImageModel.MisMatchID  = MisMatch.ID;

                            if (isAdd)
                            {
                                errorImageModel.ID = (int)pt.Insert(errorImageModel);
                            }
                            else
                            {
                                pt.Update(errorImageModel);
                            }

                            if (!DocUtils.CheckExits(ftpFolderPath))
                            {
                                DocUtils.MakeDir(ftpFolderPath);
                            }
                            DocUtils.UploadFile(filePath, ftpFolderPath);

                            pt.CommitTransaction();
                        }
                        catch (Exception)
                        {
                        }
                        finally
                        {
                            pt.CloseConnection();
                        }
                    }

                    loadGridImage();
                }
            }
        }
コード例 #23
0
ファイル: frmMisMatch.cs プロジェクト: B06-0253/NVTHAO
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                if (MisMatch.ID > 0)
                {
                    MisMatch = (MisMatchModel)MisMatchBO.Instance.FindByPK(MisMatch.ID);
                }

                MisMatch.Code        = txtCode.Text.Trim().ToUpper();
                MisMatch.Description = txtDescription.Text.Trim();
                MisMatch.StatusTK    = 0;
                MisMatch.ProjectCode = TextUtils.ToString(cboProject.EditValue);
                MisMatch.ModuleCode  = cboModule.EditValue != null?cboModule.EditValue.ToString() : "";

                MisMatch.Cost     = txtCost.Value;
                MisMatch.UserFind = TextUtils.ToInt(cboUser.EditValue);

                //MisMatch.CompleteTime = _completeTime;

                if (MisMatch.ID == 0)
                {
                    MisMatch.ID = (int)pt.Insert(MisMatch);
                }
                else
                {
                    pt.Update(MisMatch);
                }

                pt.CommitTransaction();
                _isSaved = true;

                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    groupBoxPicture.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #24
0
        void save()
        {
            grvData.Focus();

            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    _isError = true;
                    return;
                }

                WorkingDiaries.UserId       = TextUtils.ToString(cboUser.EditValue);
                WorkingDiaries.UserName     = txtUserName.Text.Trim();
                WorkingDiaries.UserCode     = txtUserCode.Text.Trim();
                WorkingDiaries.DepartmentId = TextUtils.ToString(cboPhongBan.EditValue);
                WorkingDiaries.ProjectId    = TextUtils.ToString(cboProject.EditValue);
                WorkingDiaries.ProjectCode  = txtProjectCode.Text.Trim();
                WorkingDiaries.ProjectName  = txtProjectName.Text.Trim();
                WorkingDiaries.ModuleCode   = txtModuleCode.Text.Trim();
                WorkingDiaries.ModuleName   = txtModuleName.Text.Trim();

                WorkingDiaries.WorkingContent = txtWorkingContent.Text.Trim();
                DateTime cDate = TextUtils.ToDate3(dtpWorkingDate.EditValue);
                WorkingDiaries.WorkingDate = cDate;
                WorkingDiaries.StartTime   = new DateTime(cDate.Year, cDate.Month, cDate.Day, TextUtils.ToDate3(dtpStartTime.EditValue).Hour, TextUtils.ToDate3(dtpStartTime.EditValue).Minute, 0);
                if (Global.AppUserName.ToLower() == "hien.n")
                {
                }
                else if (!validateTimeStart(WorkingDiaries.StartTime.Value))
                {
                    MessageBox.Show("Không thể nhập nhật ký do quá thời hạn.(Chậm nhất là mùng 2 tháng kế tiếp)", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    pt.CloseConnection();
                    return;
                }
                WorkingDiaries.EndTime  = new DateTime(cDate.Year, cDate.Month, cDate.Day, TextUtils.ToDate3(dtpEndTime.EditValue).Hour, TextUtils.ToDate3(dtpEndTime.EditValue).Minute, 0);
                WorkingDiaries.WorkTime = TextUtils.ToDecimal(txtWorkTime.EditValue);

                WorkingDiaries.Status = cboStatus.SelectedIndex;
                WorkingDiaries.Note   = txtNote.Text.Trim();

                //WorkingDiaries.IsApproved = txtName.Text.Trim();
                WorkingDiaries.IsNghiTrua  = chkKhongNghiTrua.Checked;
                WorkingDiaries.IsAnToi     = chkKhongAnToi.Checked;
                WorkingDiaries.WorkPercent = TextUtils.ToDecimal(txtWorkPercent.EditValue);
                WorkingDiaries.WorkingDiariesLocationID = TextUtils.ToInt(cboLocation.SelectedValue);

                WorkingDiaries.UpdatedBy   = Global.AppUserName;
                WorkingDiaries.UpdatedDate = DateTime.Now;

                if (WorkingDiaries.ID == 0)
                {
                    WorkingDiaries.CreatedBy   = Global.AppUserName;
                    WorkingDiaries.CreatedDate = DateTime.Now;
                    WorkingDiaries.ID          = (int)pt.Insert(WorkingDiaries);
                }
                else
                {
                    pt.Update(WorkingDiaries);
                }

                pt.CommitTransaction();

                _isSaved = true;
                loadData();

                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                _isError = false;

                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            catch (Exception ex)
            {
                _isError = true;
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #25
0
ファイル: frmMaterialGroupNS.cs プロジェクト: mrgrey88/QLTK
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                grvThongSo.FocusedRowHandle = -1;

                MaterialNS.Name        = txtName.Text.Trim().ToUpper();
                MaterialNS.Code        = txtCode.Text.Trim().Replace(" ", "");
                MaterialNS.CustomerID  = TextUtils.ToInt(cboHang.EditValue);
                MaterialNS.Description = txtDescription.Text.Trim();
                MaterialNS.Type        = cboType.SelectedIndex;
                MaterialNS.NumberTS    = TextUtils.ToInt(txtSL.Text);

                if (MaterialNS.ID <= 0)
                {
                    MaterialNS.ID = (int)pt.Insert(MaterialNS);
                }
                else
                {
                    pt.Update(MaterialNS);
                }

                #region Lưu trữ thông số
                for (int i = 0; i < grvThongSo.RowCount; i++)
                {
                    int    id   = TextUtils.ToInt(grvThongSo.GetRowCellValue(i, colIDThongSo));
                    string code = TextUtils.ToString(grvThongSo.GetRowCellValue(i, colCodeThongSo));
                    string name = TextUtils.ToString(grvThongSo.GetRowCellValue(i, colNameThongSo));
                    if (code == "" || name == "")
                    {
                        continue;
                    }

                    MaterialParamNSModel para = new MaterialParamNSModel();
                    if (id > 0)
                    {
                        para = (MaterialParamNSModel)MaterialParamNSBO.Instance.FindByPK(id);
                    }

                    para.Code         = code.ToUpper().Trim().Replace(" ", "");
                    para.Name         = name.Trim();
                    para.MaterialNSID = MaterialNS.ID;
                    para.Unit         = TextUtils.ToString(grvThongSo.GetRowCellValue(i, colUnitThongSo));

                    if (para.ID <= 0)
                    {
                        pt.Insert(para);
                    }
                    else
                    {
                        if (i >= TextUtils.ToInt(txtSL.Text))
                        {
                            pt.Delete("MaterialParamNS", para.ID);
                        }
                        else
                        {
                            pt.Update(para);
                        }
                    }
                }
                #endregion

                #region Lưu trữ file
                for (int i = 0; i < grvData.RowCount; i++)
                {
                    int iD = TextUtils.ToInt(grvData.Rows[i].Cells["colID"].Value);
                    MaterialFileNSModel fileModel = new MaterialFileNSModel();

                    if (iD > 0)
                    {
                        fileModel = (MaterialFileNSModel)MaterialFileNSBO.Instance.FindByPK(iD);
                    }

                    fileModel.FilePath      = grvData.Rows[i].Cells["colFilePath"].Value.ToString();
                    fileModel.Length        = TextUtils.ToDecimal(grvData.Rows[i].Cells["colSize"].Value);
                    fileModel.MaterialNSID  = MaterialNS.ID;
                    fileModel.Name          = grvData.Rows[i].Cells["colFileName"].Value.ToString();
                    fileModel.LocalFilePath = grvData.Rows[i].Cells["colLocalPath"].Value.ToString();

                    if (iD == 0)
                    {
                        pt.Insert(fileModel);
                        File.Copy(fileModel.LocalFilePath, fileModel.FilePath, true);
                    }
                }
                #endregion

                pt.CommitTransaction();
                if (grvData.Rows.Count > 0)
                {
                    MaterialNS.FilePath = TextUtils.ToString(grvData.Rows[0].Cells["colFilePath"].Value);
                    MaterialNSBO.Instance.Update(MaterialNS);
                }
                loadGridFile();
                loadGridPara();

                _isSaved = true;
                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi xảy ra khi lưu trữ!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #26
0
ファイル: frmQuotation.cs プロジェクト: B06-0253/NVTHAO
        void save()
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                grvLink.FocusedRowHandle = -1;

                CurrentQuotation.Code           = txtCode.Text.Trim();
                CurrentQuotation.CustomerCode   = txtCustomerCode.Text.Trim();
                CurrentQuotation.CustomerName   = txtCustomerName.Text.Trim();
                CurrentQuotation.DeliveryTime   = TextUtils.ToDecimal(txtDeliveryTime.EditValue);
                CurrentQuotation.DepartmentName = txtDepartmentName.Text.Trim();
                CurrentQuotation.CustomerCodeF  = txtFinishCustomerCode.Text.Trim();
                CurrentQuotation.CustomerNameF  = txtFinishCustomerName.Text.Trim();
                CurrentQuotation.POnumber       = txtPOnumber.Text.Trim();
                CurrentQuotation.ProjectCode    = txtProjectCode.Text.Trim();
                CurrentQuotation.ProjectName    = txtProjectName.Text.Trim();
                CurrentQuotation.Tax            = TextUtils.ToDecimal(txtTax.EditValue);

                CurrentQuotation.TotalCustomer = TextUtils.ToDecimal(colTotal.SummaryItem.SummaryValue);

                //CurrentQuotation.TotalBX = TextUtils.ToDecimal(txtTotalBX.EditValue);
                //CurrentQuotation.TotalHD = TextUtils.ToDecimal(txtTotalHD.EditValue);
                //CurrentQuotation.TotalNC = TextUtils.ToDecimal(txtTotalNC.EditValue);
                //CurrentQuotation.TotalPB = TextUtils.ToDecimal(txtTotalPB.EditValue);
                //CurrentQuotation.TotalProfit = TextUtils.ToDecimal(txtTotalProfit.EditValue);
                //CurrentQuotation.TotalReal = TextUtils.ToDecimal(txtTotalReal.EditValue);
                //CurrentQuotation.TotalTPA = TextUtils.ToDecimal(txtTotalTPA.EditValue);
                //CurrentQuotation.TotalVT = TextUtils.ToDecimal(txtTotalVT.EditValue);

                CurrentQuotation.Status       = cboStatus.SelectedIndex;
                CurrentQuotation.DepartmentId = TextUtils.ToInt(cboDepartment.SelectedValue);

                CurrentQuotation.CustomerPercent = TextUtils.ToDecimal(txtCustomerPercent.EditValue);
                CurrentQuotation.CustomerCash    = TextUtils.ToDecimal(txtCustomerCash.EditValue);
                //CurrentQuotation.IsCustomerVAT = chkIsCustomerVAT.Checked;
                CurrentQuotation.IsVAT = cboIsVAT.SelectedIndex;

                CurrentQuotation.UpdatedDate = DateTime.Now;
                CurrentQuotation.UpdatedBy   = Global.AppUserName;
                if (CurrentQuotation.ID <= 0)
                {
                    CurrentQuotation.CreatedDate = DateTime.Now;
                    CurrentQuotation.CreatedBy   = Global.AppUserName;
                    CurrentQuotation.ID          = (int)pt.Insert(CurrentQuotation);
                }
                else
                {
                    pt.Update(CurrentQuotation);
                }
                if (grvLink.RowCount > 0)
                {
                    for (int i = 0; i < grvLink.RowCount; i++)
                    {
                        int id = TextUtils.ToInt(grvLink.GetRowCellValue(i, colID));
                        C_CostQuotationLinkModel link = (C_CostQuotationLinkModel)C_CostQuotationLinkBO.Instance.FindByPK(id);
                        link.Qty   = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colQty));
                        link.Price = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPrice));
                        link.Total = link.Qty * link.Price;
                        pt.Update(link);
                    }
                }
                else
                {
                    DataTable dtLink = LibQLSX.Select("select * from C_Cost where IsWithProject = 1");
                    //DataTable dtLink = LibQLSX.Select("select * from C_Cost where IsWithProject = 1 or CostType = 1");
                    foreach (DataRow row in dtLink.Rows)
                    {
                        C_CostQuotationLinkModel link = new C_CostQuotationLinkModel();
                        link.C_CostID      = TextUtils.ToInt(row["ID"]);
                        link.C_QuotationID = CurrentQuotation.ID;
                        link.Price         = TextUtils.ToDecimal(row["Price"]);
                        link.Qty           = 0;
                        link.Total         = link.Qty * link.Price;
                        pt.Insert(link);
                    }
                }

                pt.CommitTransaction();
                _isSaved = true;
                loadCost();
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }

            if (_isSaved)
            {
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
        }
コード例 #27
0
ファイル: frmShowStaff.cs プロジェクト: mrgrey88/QLTK
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                Model.BankAccount = txtBankAccount.Text.Trim();
                Model.BHXH        = txtBHXH.Text.Trim();
                Model.BHYT        = txtBHYT.Text.Trim();
                try
                {
                    Model.BirthOfDate = TextUtils.ToDate(dtpBirthOfDate.EditValue.ToString());
                }
                catch
                {
                    Model.BirthOfDate = DateTime.Now;
                }

                Model.CMTND          = txtCMTND.Text.Trim();
                Model.Code           = txtCode.Text.Trim();
                Model.DepartmentID   = TextUtils.ToInt(cboDepartment.SelectedValue);
                Model.Email          = txtEmail.Text.Trim();
                Model.EmailCom       = txtEmailCom.Text.Trim();
                Model.FullName       = txtFullName.Text;
                Model.HandPhone      = txtTelephone.Text;
                Model.HomeAddress    = txtHomeAddress.Text;
                Model.JobDescription = txtJobDescription.Text.Trim();
                Model.MST            = txtMST.Text.Trim();
                Model.Position       = txtPosition.Text;
                Model.Qualifications = txtQualifications.Text.Trim();
                Model.Sex            = cboSex.SelectedIndex;
                Model.UserGroupID    = TextUtils.ToInt(lookUpEdit1.EditValue);
                try
                {
                    Model.StartWorking = TextUtils.ToDate(dtpStartWorking.EditValue.ToString());
                }
                catch
                {
                    Model.StartWorking = DateTime.Now;
                }

                Model.ImagePath = pictureBox1.ImageLocation;
                Model.Status    = cboStatus.SelectedIndex;

                if (chkHasUser.Checked)
                {
                    Model.LoginName    = txtLoginName.Text.Trim();
                    Model.PasswordHash = MD5.EncryptPassword(txtPasswordHash.Text.Trim());
                }
                else
                {
                    Model.LoginName    = "";
                    Model.PasswordHash = "";
                }

                Model.UpdatedDate = Model.CreatedDate;
                Model.UpdatedBy   = Global.AppUserName;

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;

                    Model.ID = (int)pt.Insert(Model);
                }
                else
                {
                    pt.Update(Model);
                }
                pt.CommitTransaction();
                //this.DialogResult = DialogResult.OK;
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #28
0
ファイル: frmFile3D.cs プロジェクト: B06-0253/NVTHAO
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            progressBar1.Visible = true;
            progressBar1.Minimum = 0;
            progressBar1.Maximum = grvData.RowCount;
            progressBar1.Value   = 0;

            for (int i = 0; i < grvData.RowCount; i++)
            {
                try
                {
                    string filePath = Path.Combine(_dPath, grvData.GetRowCellValue(i, colName).ToString());

                    if (filePath != grvData.GetRowCellValue(i, colPath).ToString())
                    {
                        FileInfo fi = new FileInfo(filePath);

                        if (File.Exists(filePath))
                        {
                            DialogResult result = MessageBox.Show("Đã tồn tại file: [" + grvData.GetRowCellValue(i, colName).ToString() + "] trên thư viện."
                                                                  + Environment.NewLine + "Bạn có muốn upload file không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                            if (result == DialogResult.Yes)
                            {
                                //Tạo một folder chứa file cũ
                                string folderPath = Path.GetDirectoryName(filePath) + @"\" + DateTime.Now.ToString("dd-MM-yyyy");
                                Directory.CreateDirectory(folderPath);
                                File.Copy(filePath, folderPath + @"\" + fi.Name, true);
                                File.Delete(filePath);
                                File.Copy(grvData.GetRowCellValue(i, colPath).ToString(), filePath, true);
                            }
                        }
                        else
                        {
                            File.Copy(grvData.GetRowCellValue(i, colPath).ToString(), Path.Combine(_dPath, grvData.GetRowCellValue(i, colName).ToString()));
                        }
                    }

                    //Kiểm tra đã có trong cơ sở dữ liệu hay chưa
                    ArrayList listFile = new ArrayList();
                    try
                    {
                        listFile = File3DBO.Instance.FindByExpression(new Expression("Name", Path.GetFileName(filePath))
                                                                      .And(new Expression("ProductGroupID", _gModel.ID)));
                    }
                    catch (Exception)
                    {
                    }

                    if (listFile.Count == 0)
                    {
                        File3DModel model = new File3DModel();
                        model.Datemodified   = TextUtils.ToDate(grvData.GetRowCellValue(i, colDatemodified).ToString());
                        model.Length         = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colLength));
                        model.Name           = Path.GetFileName(grvData.GetRowCellValue(i, colPath).ToString());
                        model.ProductGroupID = CatID;
                        model.Path           = @"" + filePath;
                        pt.Insert(model);
                    }
                    else
                    {
                        File3DModel model1 = (File3DModel)listFile[0];
                        model1.Length       = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colLength));
                        model1.Datemodified = TextUtils.ToDate(grvData.GetRowCellValue(i, colDatemodified).ToString());
                        pt.Update(model1);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Lỗi");
                    continue;
                }
                progressBar1.Value += i;
            }

            progressBar1.Visible = false;

            pt.CommitTransaction();
            pt.CloseConnection();
            MessageBox.Show("Lưu trữ thành công.", "Thông báo");
            DialogResult = DialogResult.OK;
        }
コード例 #29
0
ファイル: frmWorkDiary.cs プロジェクト: B06-0253/NVTHAO
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                WorkDiary.EndDateDK   = dtpEndDateDK.Value;
                WorkDiary.GhiChu      = txtNote.Text.Trim();
                WorkDiary.ModuleCode  = txtModuleCode.Text.Trim();
                WorkDiary.Name        = txtName.Text.Trim();
                WorkDiary.ProjectCode = txtProjectCode.Text.Trim();
                WorkDiary.StartDate   = dtpStartDate.Value;
                WorkDiary.Status      = cboStatus.SelectedIndex;
                //WorkDiary.ThoiGianDuKien = TextUtils.ToInt(txtTime.EditValue);
                WorkDiary.UserID = TextUtils.ToInt(cboUser.EditValue);

                if (cboStatus.SelectedIndex == 1)
                {
                    WorkDiary.EndDate = DateTime.Now;
                }
                else
                {
                    WorkDiary.EndDate = null;
                }

                if (WorkDiary.ID == 0)
                {
                    WorkDiary.ID = (int)pt.Insert(WorkDiary);

                    TheoDoiHistoryModel history = new TheoDoiHistoryModel();
                    history.EndDateDK = WorkDiary.EndDateDK;
                    history.TheoDoiID = WorkDiary.ID;
                    history.Reason    = "Thêm mới";
                    pt.Insert(history);
                }
                else
                {
                    pt.Update(WorkDiary);

                    if (_oldEndDateDK.Date != dtpEndDateDK.Value)
                    {
                        TheoDoiHistoryModel history = new TheoDoiHistoryModel();
                        history.EndDateDK = WorkDiary.EndDateDK;
                        history.TheoDoiID = WorkDiary.ID;
                        history.Reason    = txtReason.Text.Trim();
                        pt.Insert(history);
                    }
                }

                pt.CommitTransaction();
                loadHistory();
                _isSaved = true;
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }

            if (_isSaved && this.LoadDataChange != null)
            {
                this.LoadDataChange(null, null);
            }
        }
コード例 #30
0
        void save()
        {
            if (Global.AppUserName != ProposalProblem.UpdatedBy && ProposalProblem.ID > 0)
            {
                MessageBox.Show("Bạn không có quyền sửa vấn đề này!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                grvData.FocusedRowHandle    = -1;
                ProposalProblem.ProposalId  = Proposal.ProposalId;
                ProposalProblem.Reason      = txtReason.Text.Trim();
                ProposalProblem.Solution    = txtSolution.Text.Trim();
                ProposalProblem.IsCompleted = 0;
                ProposalProblem.UpdatedDate = DateTime.Now;
                ProposalProblem.UpdatedBy   = Global.AppUserName;

                if (ProposalProblem.ID <= 0)
                {
                    ProposalProblem.CreatedDate = DateTime.Now;
                    ProposalProblem.CreatedBy   = Global.AppUserName;
                    ProposalProblem.ID          = (int)pt.Insert(ProposalProblem);
                }
                else
                {
                    pt.Update(ProposalProblem);
                }

                for (int i = 0; i < grvData.RowCount; i++)
                {
                    ProposalProblemActionModel action = new ProposalProblemActionModel();
                    int id = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                    if (id > 0)
                    {
                        action = (ProposalProblemActionModel)ProposalProblemActionBO.Instance.FindByPK(id);
                    }

                    action.Action            = TextUtils.ToString(grvData.GetRowCellValue(i, colAction));
                    action.ProposalProblemID = ProposalProblem.ID;
                    action.UserId            = TextUtils.ToString(grvData.GetRowCellValue(i, colUserId));
                    action.Deadline          = TextUtils.ToDate2(grvData.GetRowCellValue(i, colDeadline));
                    action.IsCompleted       = TextUtils.ToBoolean(grvData.GetRowCellValue(i, colIsCompleted));

                    if (id > 0)
                    {
                        ProposalProblemActionBO.Instance.Update(action);
                    }
                    else
                    {
                        ProposalProblemActionBO.Instance.Insert(action);
                    }
                }

                pt.CommitTransaction();
                loadGrid();
                _isSaved = true;

                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }

            if (_isSaved)
            {
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            else
            {
                return;
            }
        }