コード例 #1
0
        void saveDN(ProcessTransaction pt, int count, DataRow row)
        {
            int     stt = TextUtils.ToInt(row["F1"]);
            decimal qty = TextUtils.ToDecimal(row["F7"]);

            C_QuotationDetail_SXModel item = new C_QuotationDetail_SXModel();

            item.C_QuotationID = Quotation.ID;
            item.ParentID      = 0;
            item.Qty           = item.QtyT = qty;
            item.PriceVT       = TextUtils.ToDecimal(row["F41"]);
            item.PriceVTTN     = TextUtils.ToDecimal(row["F42"]);
            item.PriceVTPS     = TextUtils.ToDecimal(row["F43"]);
            item.Manufacture   = TextUtils.ToString(row["F4"]);
            item.ModuleCode    = TextUtils.ToString(row["F3"]);
            item.ModuleName    = TextUtils.ToString(row["F2"]);
            item.Origin        = TextUtils.ToString(row["F5"]);

            item.C_ProductGroupID = TextUtils.ToInt(LibQLSX.ExcuteScalar("select ID from C_ProductGroup where Code = '" + TextUtils.ToString(row["F6"]) + "'"));

            item.ID = (int)pt.Insert(item);
            count++;
            row["ID"] = item.ID;

            DataRow[] drs = _dtData.Select("F1 like '" + stt + ".%'");
            foreach (DataRow rowC in drs)
            {
                decimal qtyC      = TextUtils.ToDecimal(rowC["F7"]);
                string  groupCode = TextUtils.ToString(rowC["F6"]);

                int groupID = TextUtils.ToInt(LibQLSX.ExcuteScalar("select ID from C_ProductGroup where Code = '" + groupCode + "'"));

                C_QuotationDetail_SXModel itemC = new C_QuotationDetail_SXModel();
                itemC.C_QuotationID    = Quotation.ID;
                itemC.ParentID         = item.ID;
                itemC.C_ProductGroupID = groupID;

                itemC.Qty       = qtyC;
                itemC.QtyT      = qtyC / item.Qty;
                itemC.PriceVT   = TextUtils.ToDecimal(rowC["F41"]);
                itemC.PriceVTTN = TextUtils.ToDecimal(row["F42"]);
                itemC.PriceVTPS = TextUtils.ToDecimal(row["F43"]);

                itemC.ModuleName  = TextUtils.ToString(rowC["F2"]);
                itemC.ModuleCode  = TextUtils.ToString(rowC["F3"]);
                itemC.Manufacture = TextUtils.ToString(rowC["F4"]);
                itemC.Origin      = TextUtils.ToString(rowC["F5"]);

                itemC.ID   = (int)pt.Insert(itemC);
                rowC["ID"] = itemC.ID;
                count++;
            }
        }
コード例 #2
0
        void CreateVersion(BaiThucHanhModel BaiThucHanh)
        {
            ProcessTransaction pt = new ProcessTransaction();

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

            try
            {
                // Tạo phiên bản bài thực hành
                BaiThucHanhVersionModel versionModel = new BaiThucHanhVersionModel();
                versionModel.BaiThucHanhID = BaiThucHanh.ID;
                versionModel.Reason        = "Tạo phiên bản đầu tiên";
                versionModel.Version       = BaiThucHanh.Version;
                versionModel.ID            = (int)pt.Insert(versionModel);

                //Tạo các phiên bản module bài thực hành
                ArrayList lisModules = BaiThucHanhModuleBO.Instance.FindByAttribute("BaiThucHanhID", BaiThucHanh.ID);
                if (lisModules.Count > 0)
                {
                    foreach (var item in lisModules)
                    {
                        BaiThucHanhModuleModel thisModule = (BaiThucHanhModuleModel)item;

                        BaiThucHanhModuleVersionModel moduleVersion = new BaiThucHanhModuleVersionModel();
                        moduleVersion.BTHVersionID = 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);
                    }
                }

                pt.CommitTransaction();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
0
        private void btnCopyN_Click(object sender, EventArgs e)
        {
            //chuyển thông số đích sang nguồns

            int groupID = TextUtils.ToInt(cboMaterialGroupN.EditValue);

            if (groupID == 0)
            {
                MessageBox.Show("Bạn hãy chọn nhóm vật tư.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            foreach (int rowHandle in grvData.GetSelectedRows())
            {
                string    name = grvData.GetRowCellValue(rowHandle, colNameN).ToString();
                DataTable dt;
                dt = TextUtils.Select("select Name from MaterialParameters where MaterialGroupID =" + groupID + " and Name = N'" + name + "'");
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("Tên thông số [" + name + "] này đã tồn tại!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        continue;
                    }
                }

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

                    model.CreatedDate = TextUtils.GetSystemDate();
                    model.CreatedBy   = Global.AppUserName;
                    model.UpdatedDate = model.CreatedDate;
                    model.UpdatedBy   = Global.AppUserName;

                    model.Name            = grvData.GetRowCellValue(rowHandle, colNameN).ToString();
                    model.MaterialGroupID = TextUtils.ToInt(cboMaterialGroupN.EditValue);

                    DataTable dtmax = TextUtils.Select("SELECT isnull(MAX(STT),0) FROM MaterialParameters with(nolock) where MaterialParameters.MaterialGroupID = "
                                                       + model.MaterialGroupID);
                    model.STT = TextUtils.ToInt(dtmax.Rows[0][0].ToString()) + 1;

                    pt.Insert(model);
                    pt.CommitTransaction();
                    loadGridParasN();
                }
                catch (Exception)
                {
                }
                finally
                {
                    pt.CloseConnection();
                }
            }
        }
コード例 #6
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();
            }
        }
コード例 #7
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();
            }
        }
コード例 #8
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();
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
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(); }
        }
コード例 #11
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();
            }
        }
コード例 #12
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();
            }
        }
コード例 #13
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();
            }
        }
コード例 #14
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();
            }
        }
コード例 #15
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();
            }
        }
コード例 #16
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();
            }
        }
コード例 #17
0
        void saveGiaTri(ProcessTransaction pt)
        {
            if (treeValue.Nodes.Count == 0)
            {
                return;
            }
            int paraID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (paraID == 0)
            {
                return;
            }
            if (Material.ID <= 0)
            {
                return;
            }
            for (int i = 0; i < treeValue.Nodes.Count; i++)
            {
                int valID = TextUtils.ToInt(treeValue.GetNodeByVisibleIndex(i).GetValue(colIDValue));

                DataTable dt = TextUtils.Select("MaterialConnect", new Expression("MaterialID", Material.ID)
                                                .And(new Expression("MaterialParameterID", paraID))
                                                .And(new Expression("MaterialParameterValueID", valID)));

                if (dt.Rows.Count > 0)
                {
                    if (!treeValue.GetNodeByVisibleIndex(i).Checked)
                    {
                        pt.Delete("MaterialConnect", TextUtils.ToInt(dt.Rows[0]["ID"]));
                    }
                }
                else
                {
                    if (treeValue.GetNodeByVisibleIndex(i).Checked)
                    {
                        MaterialConnectModel modelM = new MaterialConnectModel();
                        modelM.MaterialID               = Material.ID;
                        modelM.MaterialParameterID      = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                        modelM.MaterialParameterValueID = valID;
                        pt.Insert(modelM);
                    }
                }
            }
        }
コード例 #18
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();
            }
        }
コード例 #19
0
ファイル: frmImportErrorPart.cs プロジェクト: mrgrey88/QLTK
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            //KcsError
            string criteriaImportId = TextUtils.ToString(grvData.GetFocusedRowCellValue(colCriteriaImportId));

            //string orderCode = TextUtils.ToString(grvOrder.GetFocusedRowCellValue(colSoDonHang));

            if (criteriaImportId == "")
            {
                return;
            }

            DocUtils.InitFTPTK();

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (string filePath in ofd.FileNames)
                {
                    FileInfo fInfo = new FileInfo(filePath);

                    ProcessTransaction pt = new ProcessTransaction();
                    pt.OpenConnection();
                    pt.BeginTransaction();

                    try
                    {
                        CriteriaImportImageModel model = new CriteriaImportImageModel();
                        model.CriteriaImportId = criteriaImportId;
                        model.FileName         = fInfo.Name;
                        //model.FileLocalPath = fInfo.FullName;
                        model.FilePath    = "KcsError\\" + criteriaImportId + "\\" + fInfo.Name;
                        model.Size        = fInfo.Length;
                        model.DateCreated = TextUtils.GetSystemDate();
                        pt.Insert(model);
                        if (!DocUtils.CheckExits("KcsError\\" + criteriaImportId + "\\"))
                        {
                            DocUtils.MakeDir("KcsError\\" + criteriaImportId + "\\");
                        }
                        bool status = DocUtils.UploadFileWithStatus(filePath, "KcsError\\" + criteriaImportId);
                        if (status)
                        {
                            pt.CommitTransaction();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        pt.CloseConnection();
                    }
                }

                loadImge(criteriaImportId);
            }
        }
コード例 #20
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);
                }
            }
        }
コード例 #21
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);
            }
        }
コード例 #22
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();
            }
        }
コード例 #23
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();
            }
        }
コード例 #24
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();
            }
        }
コード例 #25
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();
            }
        }
コード例 #26
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();
        }
コード例 #27
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();
            }
        }
コード例 #28
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();
            }
        }
コード例 #29
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();
                }
            }
        }
コード例 #30
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();
            }
        }