Пример #1
0
 private void btnApprove_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn xóa hoàn toàn những file này không?",
                         TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
     {
         return;
     }
     foreach (int item in grvGrid.GetSelectedRows())
     {
         int mID = TextUtils.ToInt(grvGrid.GetRowCellValue(item, colMaterialFileID));
         ProcessTransaction pt = new ProcessTransaction();
         pt.OpenConnection();
         pt.BeginTransaction();
         try
         {
             //Delete file in ftp
             DocUtils.DeleteFile(grvGrid.GetRowCellValue(item, colPath).ToString());
             //
             pt.Delete("MaterialFile", mID);
             pt.DeleteByAttribute("MaterialFileLink", "MaterialFileID", mID.ToString());
             pt.CommitTransaction();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         finally
         {
             pt.CloseConnection();
         }
     }
 }
Пример #2
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (grvData.DataSource == null)
                {
                    return;
                }
                int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                if (id == 0)
                {
                    return;
                }

                if (MaterialFileLinkBO.Instance.CheckExist("MaterialID", id))
                {
                    if (MessageBox.Show("Vật tư [" + grvData.GetFocusedRowCellValue(colName).ToString() + "] đang liên kết với các file thư viện.\n Bạn có thật sự muốn xóa nó không?",
                                        TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.No)
                    {
                        return;
                    }
                    DataTable dt = TextUtils.Select("select Path,MaterialID,MaterialCode from vMaterialFile with(nolock) where FileType = 0 and MaterialID = " + id);
                    if (dt.Rows.Count > 0)
                    {
                        DocUtils.InitFTPTK();
                        DocUtils.DeleteFile(dt.Rows[0][0].ToString());
                    }
                    pt.Delete("Material", id);
                    pt.DeleteByAttribute("MaterialConnect", "MaterialID", id.ToString());
                    pt.DeleteByAttribute("MaterialParameterLink", "MaterialID", id.ToString());
                    pt.DeleteByAttribute("MaterialFileLink", "MaterialID", id.ToString());
                }
                else
                {
                    if (MessageBox.Show("Bạn có chắc muốn xóa vật tư [" + grvData.GetFocusedRowCellValue(colName).ToString() + "] không?",
                                        TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    pt.Delete("Material", id);
                    pt.DeleteByAttribute("MaterialConnect", "MaterialID", id.ToString());
                    pt.DeleteByAttribute("MaterialParameterLink", "MaterialID", id.ToString());
                }

                pt.CommitTransaction();
                LoadInfoSearch();
            }
            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(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();
            }
        }
Пример #7
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();
            }
        }
Пример #8
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.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 btnDelete_Click(object sender, EventArgs e)
        {
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang xóa file..."))
            {
                if (grvData.RowCount <= 0)
                {
                    return;
                }

                int materialFileID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                if (materialFileID == 0)
                {
                    return;
                }

                string filePath = grvData.GetFocusedRowCellValue(colPath).ToString();
                string fileName = grvData.GetFocusedRowCellValue(colFileName).ToString();

                DataTable dt = TextUtils.Select("MaterialFileLink", new Expression("MaterialFileID", materialFileID));
                if (dt.Rows.Count >= 1)
                {
                    MessageBox.Show("File [" + fileName + "]" + " đã được đính kèm với nhiều vật tư.\n Bạn không thế xóa file này!", TextUtils.Caption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Question);
                    return;
                }

                if (MessageBox.Show("Bạn có thật sự muốn xóa file [" + fileName + "] này không?", TextUtils.Caption,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                ProcessTransaction pt = new ProcessTransaction();
                pt.OpenConnection();
                pt.BeginTransaction();
                try
                {
                    pt.Delete("MaterialFile", materialFileID);
                    pt.DeleteByAttribute("MaterialFileLink", "MaterialFileID", materialFileID.ToString());

                    DocUtils.DeleteFile(filePath);
                    pt.CommitTransaction();
                }
                catch (Exception)
                {
                }
                finally
                {
                    pt.CloseConnection();
                }
                loadGrid();
            }
        }
Пример #10
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);
            }
        }
Пример #11
0
        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(); }
        }
Пример #12
0
        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 btnDeleteFile_Click(object sender, EventArgs e)
        {
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang xóa file lên server!"))
            {
                DocUtils.InitFTPTK();
                if (grvDataImage.RowCount <= 0)
                {
                    return;
                }

                int id = TextUtils.ToInt(grvDataImage.SelectedRows[0].Cells[colID.Name].Value);
                if (id == 0)
                {
                    return;
                }

                string filePath = grvDataImage.SelectedRows[0].Cells[colFilePath.Name].Value.ToString();
                string fileName = grvDataImage.SelectedRows[0].Cells[colFileName.Name].Value.ToString();

                if (MessageBox.Show("Bạn có thật sự muốn xóa file [" + fileName + "] này không?", TextUtils.Caption,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                ProcessTransaction pt = new ProcessTransaction();
                pt.OpenConnection();
                pt.BeginTransaction();
                try
                {
                    pt.Delete("MisMatchImage", id);

                    if (DocUtils.CheckExits(filePath))
                    {
                        DocUtils.DeleteFile(filePath);
                    }

                    pt.CommitTransaction();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Xóa file [" + fileName + "] không thành công!" + Environment.NewLine + ex.Message,
                                    TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                finally
                {
                    pt.CloseConnection();
                }
                loadGridImage();
            }
        }
Пример #14
0
        private void btnDeleteFile_Click(object sender, EventArgs e)
        {
            DocUtils.InitFTPTK();
            if (grvFile.RowCount <= 0)
            {
                return;
            }

            int id = TextUtils.ToInt(grvFile.GetFocusedRowCellValue(colFileID));

            string filePath = TextUtils.ToString(grvFile.GetFocusedRowCellValue(colFileLocalPath));
            string fileName = Path.GetFileName(filePath);

            if (MessageBox.Show("Bạn có thật sự muốn xóa file [" + fileName + "] này không?", TextUtils.Caption,
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            if (id == 0)
            {
                grvFile.DeleteSelectedRows();
            }
            else
            {
                ProcessTransaction pt = new ProcessTransaction();
                pt.OpenConnection();
                pt.BeginTransaction();
                try
                {
                    pt.Delete("SolutionFile", id);

                    if (DocUtils.CheckExits(filePath))
                    {
                        DocUtils.DeleteFile(filePath);
                    }

                    pt.CommitTransaction();
                    grvFile.DeleteSelectedRows();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Xóa file [" + fileName + "] không thành công!" + Environment.NewLine + ex.Message,
                                    TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                finally
                {
                    pt.CloseConnection();
                }
            }
        }
Пример #15
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 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();
            }
        }
Пример #16
0
        void save()
        {
            ProcessTransaction pt = new ProcessTransaction();

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

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

                //PartA.Name = txtName.Text.Trim().ToUpper();
                //PartA.Code = txtCode.Text.Trim().ToUpper();
                //PartA.Type = cboType.SelectedIndex;
                //PartA.Unit = txtUnit.Text.Trim();
                PartA.QtyMin = TextUtils.ToDecimal(txtQtyMin.EditValue);
                PartA.QtyDM  = TextUtils.ToDecimal(txtQtyDM.EditValue);

                PartA.ProjectPercent = TextUtils.ToDecimal(txtProjectPercent.EditValue);
                //PartA.Price = TextUtils.ToDecimal(txtPrice.EditValue);
                PartA.IsProject = PartA.ProjectPercent > 0 ? 1 : 0;
                PartA.Qty       = TextUtils.ToDecimal(txtQty.EditValue);
                //PartA.Hang = txtHang.Text.Trim();

                //if (PartA.ID == 0)
                //{
                //    PartA.ID = (int)pt.Insert(PartA);
                //}
                //else
                //{
                pt.UpdateQLSX(PartA);
                //}

                pt.CommitTransaction();

                _isSaved = true;

                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();
            }
        }
Пример #17
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();
            }
        }
Пример #18
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();
            }
        }
Пример #19
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();
            }
        }
Пример #20
0
        private void btnDeleteApprove_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                for (int i = 0; i < grvData.RowCount; i++)
                {
                    if (grvData.DataSource == null)
                    {
                        return;
                    }
                    int id = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                    if (id == 0)
                    {
                        return;
                    }
                    File3DModel model = (File3DModel)File3DBO.Instance.FindByPK(id);
                    if (!model.IsDeleted)
                    {
                        continue;
                    }

                    if (MessageBox.Show("Bạn có chắc muốn duyệt xóa file [" + grvData.GetFocusedRowCellValue(colName).ToString() + "] ?",
                                        TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        continue;
                    }

                    pt.Delete("File3D", id);
                    File.Delete(model.Path);
                }
                pt.CommitTransaction();
                LoadInfoSearch();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
Пример #21
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();
            }
        }
Пример #22
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();
            }
        }
Пример #23
0
        private void btnDeleteGroup_Click(object sender, EventArgs e)
        {
            if (grvData.RowCount > 0)
            {
                if (MessageBox.Show("Bạn có chắc chắn muốn xóa?", TextUtils.Caption, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    ProcessTransaction pt = new ProcessTransaction();
                    pt.OpenConnection();
                    pt.BeginTransaction();
                    int id = (int)grvData.GetRowCellValue(grvData.FocusedRowHandle, "ID");
                    pt.Delete("VatTuThayThe", id);
                    pt.CommitTransaction();
                    pt.CloseConnection();

                    LoadGrid();
                }
            }
        }
Пример #24
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();
            }
        }
Пример #25
0
        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();
            }
        }
Пример #26
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (grvData.DataSource == null)
                {
                    return;
                }
                int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                if (id == 0)
                {
                    return;
                }

                if (MessageBox.Show("Bạn có chắc muốn xóa vật tư [" + grvData.GetFocusedRowCellValue(colCode).ToString() + "] không?",
                                    TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                pt.DeleteByAttribute("BaoGiaItem", "BaoGiaID", id.ToString());
                pt.Delete("BaoGia", id);

                pt.CommitTransaction();
                LoadInfoSearch();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
Пример #27
0
        private void btnDeleteN_Click(object sender, EventArgs e)
        {
            if (!grvDataN.IsDataRow(grvDataN.FocusedRowHandle))
            {
                return;
            }

            int strID = TextUtils.ToInt(grvDataN.GetRowCellValue(grvDataN.FocusedRowHandle, "ID").ToString());

            string strName = grvDataN.GetRowCellValue(grvDataN.FocusedRowHandle, "Name").ToString();

            if (MessageBox.Show(String.Format("Bạn có chắc muốn xóa thông số [{0}] không?", strName), TextUtils.Caption, MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                pt.Delete("MaterialParameters", strID);
                loadGridParasN();
                pt.DeleteByAttribute("MaterialConnect", "MaterialParameterID", strID.ToString());
                pt.DeleteByAttribute("MaterialParameterValue", "MaterialParameterID", strID.ToString());

                pt.CommitTransaction();
            }
            catch
            {
                MessageBox.Show("Có lỗi xảy ra khi thực hiện thao tác, xin vui lòng thử lại sau.");
            }
            finally
            {
                pt.CloseConnection();
            }
        }
Пример #28
0
        private void btnSaveTS_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                //Lưu trữ giá trị thông số
                saveGiaTri(pt);
                _isSaved = true;
                pt.CommitTransaction();
                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();
            }
        }
Пример #29
0
        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);
            }
        }
Пример #30
0
        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);
            }
        }