コード例 #1
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();
            }
        }
コード例 #2
0
ファイル: TextUtilss.cs プロジェクト: B06-0253/NVTHAO
        /// <summary>
        /// Insert du lieu vao History
        /// </summary>
        /// <param name="Action">Hanh dong "Insert" - "Update" - "Delete"</param>
        /// <param name="Model">Model cua doi tuong can ghi</param>
        /// <param name="pt">ProcessTransaction</param>
        public static void InsertHistory(string Action, BaseModel Model, ProcessTransaction pt)
        {
            //#region Khai bao model History

            //DateTime SysDate = GetSystemDate();
            //DateTime BusinessDate = GetBusinessDate();
            //PropertyInfo[] propertiesName = Model.GetType().GetProperties();

            //HistoryModel mH = new HistoryModel();
            //mH.Action = Action;
            //mH.BusinessDate = BusinessDate;
            //mH.ComputerName = GetHostName();
            //mH.Content = TextUtils.GetXmlContent(Model);
            //mH.CreateDate = SysDate;
            //mH.ObjectID = Convert.ToInt32(propertiesName[0].GetValue(Model, null));
            //mH.SystemDate = SysDate;
            //mH.TableName = Model.GetType().Name.Substring(0, Model.GetType().Name.Length - 5);
            //mH.UpdateDate = SysDate;
            //mH.UserID = Global.UserID;
            //mH.UserName = Global.UserName;
            //mH.UserInsertID = Global.UserID;
            //mH.UserUpdateID = Global.UserID;

            //#endregion

            //#region Insert to history

            //pt.Insert(mH);

            //#endregion
        }
        public void ProcessTransaction_GivenThatTransactionRequestIsValid_ShouldCreateTransactionSendMessageAndReturnTransaction()
        {
            Environment.SetEnvironmentVariable("QueueName", "teste123");
            var transactionRequest = new TransactionRequest
            {
                AccountOrigin      = "123",
                AccountDestination = "456",
                Value = 55.32F
            };
            var transaction = new Transaction
            {
                TransactionRequest = transactionRequest,
                TransactionId      = Guid.NewGuid().ToString(),
                Status             = new StatusResponse
                {
                    Status  = TransactionStatus.In_Queue.ToString(),
                    Message = ""
                }
            };
            var transactionRegistersRepositoryMock = new Mock <ITransactionRegistersRepository>();
            var rabbitMQProducerClientMock         = new Mock <IRabbitMQProducerClient>();

            IProcessTransaction processTransaction = new ProcessTransaction(
                transactionRegistersRepositoryMock.Object, rabbitMQProducerClientMock.Object
                );
            var result = processTransaction.Execute(transactionRequest);

            transactionRegistersRepositoryMock.Verify(repoMock => repoMock.Create(It.IsAny <Transaction>()), Times.Once);
            rabbitMQProducerClientMock.Verify(queueMock => queueMock.SendMessage("teste123", It.IsAny <string>()), Times.Once);
            Assert.AreEqual(result.Status.Message, transaction.Status.Message);
            Assert.AreEqual(result.Status.Status, transaction.Status.Status);
            Assert.AreEqual(result.TransactionRequest, transaction.TransactionRequest);
        }
コード例 #4
0
ファイル: frmApprove.cs プロジェクト: B06-0253/NVTHAO
 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();
         }
     }
 }
コード例 #5
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();
            }
        }
コード例 #6
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();
                }
            }
        }
コード例 #7
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();
            }
        }
コード例 #8
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();
            }
        }
コード例 #9
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();
            }
        }
コード例 #10
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();
            }
        }
コード例 #11
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);
            }
        }
コード例 #12
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++;
            }
        }
コード例 #13
0
ファイル: frmDatasheet.cs プロジェクト: B06-0253/NVTHAO
        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();
            }
        }
コード例 #14
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(); }
        }
コード例 #15
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();
                }
            }
        }
コード例 #16
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();
            }
        }
コード例 #17
0
ファイル: frmMisMatch.cs プロジェクト: B06-0253/NVTHAO
        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();
            }
        }
コード例 #18
0
ファイル: frmPartsGeneral.cs プロジェクト: B06-0253/NVTHAO
        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();
            }
        }
コード例 #19
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();
            }
        }
コード例 #20
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();
            }
        }
コード例 #21
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();
            }
        }
コード例 #22
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();
            }
        }
コード例 #23
0
ファイル: frm3DDienTuManager.cs プロジェクト: B06-0253/NVTHAO
        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();
            }
        }
コード例 #24
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();
            }
        }
コード例 #25
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();
            }
        }
コード例 #26
0
ファイル: frmVatTuThayThe.cs プロジェクト: B06-0253/NVTHAO
        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();
                }
            }
        }
コード例 #27
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();
            }
        }
コード例 #28
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);
                    }
                }
            }
        }
コード例 #29
0
ファイル: frmProductPrice.cs プロジェクト: B06-0253/NVTHAO
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

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

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

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

                pt.Update(Product);

                pt.CommitTransaction();
                _isSaved = true;

                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
            if (_isSaved && close)
            {
                this.Close();
            }
        }
コード例 #30
0
        public static async Task <HttpResponseMessage> CreateTransaction(ProcessTransaction processTransaction)
        {
            var client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            DefaultContractResolver contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };

            var transactionRequestString = JsonConvert.SerializeObject(processTransaction, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
            });

            var content = new StringContent(transactionRequestString, Encoding.UTF8, "application/json");

            return(await client.PostAsync(AuthorizeUrl, content));
        }