Example #1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }

            DesignSummaryModel model = (DesignSummaryModel)DesignSummaryBO.Instance.FindByPK(id);

            if (model.UpdatedBy != Global.AppUserName)
            {
                MessageBox.Show("Bạn không có quyền xóa THTK này.", TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (model.IsApproved)
            {
                MessageBox.Show("Tổng hợp thiết kế đã được duyệt.\n Bạn không thể xóa được.", TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            DialogResult result = MessageBox.Show("Bạn có chắc muốn xóa tổng hợp thiết kế này?", TextUtils.Caption,
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                DesignSummaryBO.Instance.Delete(id);
                grvData.DeleteSelectedRows();
            }
        }
Example #2
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            int userID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colUserID));

            if (userID != Global.UserID)
            {
                MessageBox.Show("Bạn không có quyền sửa công việc này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                return;
            }
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            TheoDoiModel model = (TheoDoiModel)TheoDoiBO.Instance.FindByPK(id);

            _rownIndex = grvData.FocusedRowHandle;

            frmWorkDiary frm = new frmWorkDiary();

            frm.WorkDiary       = model;
            frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
Example #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (grvTong.RowCount == 0)
            {
                return;
            }

            for (int i = 0; i < grvTong.RowCount; i++)
            {
                ProjectDirectionDetailModel model = new ProjectDirectionDetailModel();
                long id = TextUtils.ToInt64(grvTong.GetRowCellValue(i, colID));
                if (id > 0)
                {
                    model = (ProjectDirectionDetailModel)ProjectDirectionDetailBO.Instance.FindByPK(id);
                }

                model.EndDate                = TextUtils.ToDate2(grvTong.GetRowCellValue(i, colEndDate));
                model.EndDateDK              = TextUtils.ToDate2(grvTong.GetRowCellValue(i, colEndDateDK));
                model.FilePath               = TextUtils.ToString(grvTong.GetRowCellValue(i, colFilePath));
                model.MakeTime               = TextUtils.ToDecimal(grvTong.GetRowCellValue(i, colMakeTime));
                model.Material               = TextUtils.ToString(grvTong.GetRowCellValue(i, colMaterial));
                model.MaVatLieu              = TextUtils.ToString(grvTong.GetRowCellValue(i, colMaVatLieu));
                model.ModuleCode             = TextUtils.ToString(grvTong.GetRowCellValue(i, colModuleCode));
                model.PartsCode              = TextUtils.ToString(grvTong.GetRowCellValue(i, colPartsCode));
                model.PartsName              = TextUtils.ToString(grvTong.GetRowCellValue(i, colPartsName));
                model.ProjectCode            = _projectDirection.ProjectCode;
                model.ProjectDirectionID     = ProjectDirectionID;
                model.ProjectDirectionTypeID = TextUtils.ToInt(grvTong.GetRowCellValue(i, colProjectDirectionTypeID));
                model.ProjectModuleId        = "";
                model.Qty         = TextUtils.ToDecimal(grvTong.GetRowCellValue(i, colQty));
                model.StartDate   = TextUtils.ToDate2(grvTong.GetRowCellValue(i, colStartDate));
                model.StartDateDK = TextUtils.ToDate2(grvTong.GetRowCellValue(i, colStartDateDK));
                model.EndDate     = TextUtils.ToDate2(grvTong.GetRowCellValue(i, colEndDate));
                model.EndDateDK   = TextUtils.ToDate2(grvTong.GetRowCellValue(i, colEndDateDK));
                model.STT         = TextUtils.ToString(grvTong.GetRowCellValue(i, colSTT));
                model.ThongSo     = "TPA";
                model.Unit        = TextUtils.ToString(grvTong.GetRowCellValue(i, colUnit));
                model.UserId      = TextUtils.ToString(grvTong.GetRowCellValue(i, colUserId));

                if (id > 0)
                {
                    ProjectDirectionDetailBO.Instance.Update(model);
                }
                else
                {
                    model.IsNew       = 1;
                    model.IsDeleted   = 0;
                    model.CreatedBy   = Global.AppUserName;
                    model.CreatedDate = DateTime.Now;
                    ProjectDirectionDetailBO.Instance.Insert(model);
                }
            }

            loadGrid();
        }
Example #4
0
        private void grvData_DoubleClick(object sender, EventArgs e)
        {
            long paymentTableID = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colPaymentTableID));

            if (paymentTableID == 0)
            {
                return;
            }
            PaymentTableModel model = (PaymentTableModel)PaymentTableBO.Instance.FindByPK(paymentTableID);

            frmPaymentTableItem frm = new frmPaymentTableItem();

            frm.PaymentTable = model;
            //frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
Example #5
0
        private void btnDeleteDebt_Click(object sender, EventArgs e)
        {
            if (grvDebt.SelectedRowsCount == 0)
            {
                return;
            }

            foreach (int i in grvDebt.GetSelectedRows())
            {
                long id = TextUtils.ToInt64(grvDebt.GetRowCellValue(i, colDebtID));
                PayVoucherDebtModel model = (PayVoucherDebtModel)PayVoucherDebtBO.Instance.FindByPK(id);
                model.CompletedDate = TextUtils.GetSystemDate();
                PayVoucherDebtBO.Instance.Update(model);
            }
            loadDebt();
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            UpdateSoftwareModel model = (UpdateSoftwareModel)UpdateSoftwareBO.Instance.FindByPK(id);

            _rownIndex = grvData.FocusedRowHandle;

            frmErrorAndFeature frm = new frmErrorAndFeature();

            frm.UpdateSoftware  = model;
            frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
Example #7
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            PartBorrowModel model = (PartBorrowModel)PartBorrowBO.Instance.FindByPK(id);

            _rownIndex = grvData.FocusedRowHandle;

            frmPartBorrow frm = new frmPartBorrow();

            frm.PartBorrow      = model;
            frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
Example #8
0
 private void btnSaveDateDK_Click(object sender, EventArgs e)
 {
     grvDebt.FocusedRowHandle = -1;
     for (int i = 0; i < grvDebt.RowCount; i++)
     {
         try
         {
             long id = TextUtils.ToInt64(grvDebt.GetRowCellValue(i, colDebtID));
             PayVoucherDebtModel model = (PayVoucherDebtModel)PayVoucherDebtBO.Instance.FindByPK(id);
             model.CompletedDateDK = TextUtils.ToDate(grvDebt.GetFocusedRowCellValue(colDebtCompletedDateDK).ToString());
             PayVoucherDebtBO.Instance.Update(model);
         }
         catch (Exception)
         {
         }
     }
     MessageBox.Show("Lưu trữ ngày trả dự kiến thànhg công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Example #9
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }

            if (MessageBox.Show("Bạn có chắc muốn xóa theo dõi vật tư [" + grvData.GetFocusedRowCellValue(colPartsCode).ToString() + "] không?",
                                TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            _rownIndex = grvData.FocusedRowHandle;
            PartBorrowBO.Instance.Delete(id);

            loadData();
        }
Example #10
0
        private void btnVouchers_Click(object sender, EventArgs e)
        {
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));
            PaymentTableItemModel item = new PaymentTableItemModel();

            if (id > 0)
            {
                item = (PaymentTableItemModel)PaymentTableItemBO.Instance.FindByPK(id);
            }
            else
            {
                MessageBox.Show("Bạn phải Ghi lại dữ liệu trước khi thêm chứng từ nợ.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            frmVouchers frm = new frmVouchers();

            frm.PaymentTableItem = item;
            frm.Show();
        }
Example #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string userID = TextUtils.ToString(cboUser.EditValue);

            if (userID == "")
            {
                return;
            }
            string userName = TextUtils.ToString(grvCboUser.GetFocusedRowCellValue(colFullName));

            int[] listHandle = grvM.GetSelectedRows();
            int   count      = 0;

            foreach (int i in listHandle)
            {
                long linkID = TextUtils.ToInt64(grvM.GetRowCellValue(i, colMLinkID));
                PartUserLinkModel linkModel = new PartUserLinkModel();
                if (linkID > 0)
                {
                    linkModel = (PartUserLinkModel)PartUserLinkBO.Instance.FindByPK(linkID);
                }
                linkModel.UserId  = userID;
                linkModel.PartsId = TextUtils.ToString(grvM.GetRowCellValue(i, colMPartsId));
                if (linkID > 0)
                {
                    PartUserLinkBO.Instance.Update(linkModel);
                }
                else
                {
                    PartUserLinkBO.Instance.Insert(linkModel);
                }

                grvM.SetRowCellValue(i, colMLinkID, linkID);
                grvM.SetRowCellValue(i, colMUserId, userID);
                grvM.SetRowCellValue(i, colMUserName, userName);
                count++;
            }
            if (count > 0)
            {
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #12
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            long         id     = TextUtils.ToInt64(grvTong.GetFocusedRowCellValue(colID));
            DialogResult result = MessageBox.Show("Bạn có chắc muốn xóa đối tượng này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (id > 0)
                {
                    ProjectDirectionDetailModel model = (ProjectDirectionDetailModel)ProjectDirectionDetailBO.Instance.FindByPK(id);
                    model.IsDeleted = 1;
                    ProjectDirectionDetailBO.Instance.Update(model);
                    //ProjectDirectionDetailBO.Instance.Delete(id);
                    loadGrid();
                }
                else
                {
                    grvTong.DeleteSelectedRows();
                }
            }
        }
Example #13
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string cusCode = TextUtils.ToString(cboKH.EditValue);
            long   ycID    = TextUtils.ToInt64(grvYC.GetFocusedRowCellValue(colYCID));

            if (cusCode == "")
            {
                MessageBox.Show("Bạn phải chọn một khách hàng!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            if (ycID == 0)
            {
                MessageBox.Show("Bạn phải chọn một yêu cầu!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            frmSolution frm = new frmSolution();

            frm.CustomerCode    = cusCode;
            frm.RequireID       = ycID;
            frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
Example #14
0
        private void grvDebt_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                long   id      = TextUtils.ToInt64(grvDebt.GetFocusedRowCellValue(colDebtID));
                string strName = TextUtils.ToString(grvDebt.GetFocusedRowCellValue(colDebtName));

                if (MessageBox.Show(String.Format("Bạn có chắc muốn xóa [{0}] không?", strName), TextUtils.Caption,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        PayVoucherDebtBO.Instance.Delete(id);
                        loadDebt();
                    }
                    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.");
                    }
                }
            }
        }
Example #15
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            DesignSummaryModel model = (DesignSummaryModel)DesignSummaryBO.Instance.FindByPK(id);

            //if (model.UpdatedBy != Global.AppUserName)
            //{
            //    MessageBox.Show("Bạn không có quyền sửa THTK này.", TextUtils.Caption,
            //       MessageBoxButtons.OK, MessageBoxIcon.Stop);
            //    return;
            //}

            frmDesignSummary frm = new frmDesignSummary();

            frm.DesignSummary   = model;
            frm.LoadDataChange += main_LoadDataChange;
            frm.Show();
        }
Example #16
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            if (PaymentTableItemBO.Instance.CheckExist("PaymentTableID", id))
            {
                MessageBox.Show("Đề nghị thanh toán này đang chứa vụ việc nên không thể xóa được.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            if (MessageBox.Show("Bạn có chắc muốn xóa bảng kê thanh toán [" + grvData.GetFocusedRowCellValue(colNumber).ToString() + "] không?",
                                TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            PaymentTableModel model = (PaymentTableModel)PaymentTableBO.Instance.FindByPK(id);

            model.IsDeleted = true;
            PaymentTableBO.Instance.Update(model);
            LoadInfoSearch();
        }
        void save()
        {
            ProcessTransaction pt = new ProcessTransaction();

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

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

                Action.Action           = txtAction.Text.Trim();
                Action.CompletedDate    = (DateTime?)dtpDateCompleted.EditValue;
                Action.Result           = txtResult.Text.Trim();
                Action.IsCompleted      = chkIsCompleted.Checked;
                Action.ProjectProblemID = ProjectProblemID;

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

                for (int i = 0; i < grvData.RowCount; i++)
                {
                    long id = TextUtils.ToInt64(grvData.GetRowCellValue(i, colID));
                    ProjectProblemActionUserLinkModel model = new ProjectProblemActionUserLinkModel();
                    if (id > 0)
                    {
                        model = (ProjectProblemActionUserLinkModel)ProjectProblemActionUserLinkBO.Instance.FindByPK(id);
                    }

                    model.UserId = TextUtils.ToString(grvData.GetRowCellValue(i, colUserId));
                    model.ProjectProblemActionID = Action.ID;

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

                pt.CommitTransaction();

                loadGrid();
                _isSaved = true;

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

            if (_isSaved)
            {
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
        }
Example #18
0
        private void btnExcel_Click(object sender, EventArgs e)
        {
            long id = TextUtils.ToInt64(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            PaymentTableModel PaymentTable = (PaymentTableModel)PaymentTableBO.Instance.FindByPK(id);

            string path             = "";
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                path = fbd.SelectedPath;
            }
            else
            {
                return;
            }

            string filePath    = Application.StartupPath + "\\Templates\\BKTT.xlsx";
            string currentPath = path + "\\" + PaymentTable.Number + ".xlsx";

            try
            {
                File.Copy(filePath, currentPath, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Có lỗi khi tạo bảng kê thanh toán!" + Environment.NewLine + ex.Message,
                                TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo biểu mẫu..."))
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
                Excel.Application app       = default(Excel.Application);
                Excel.Workbook    workBoook = default(Excel.Workbook);
                Excel.Worksheet   workSheet = default(Excel.Worksheet);
                try
                {
                    app = new Excel.Application();
                    app.Workbooks.Open(currentPath);
                    workBoook = app.Workbooks[1];
                    workSheet = (Excel.Worksheet)workBoook.Worksheets[1];

                    workSheet.Cells[6, 1]  = "(Số: " + PaymentTable.Number + ")";
                    workSheet.Cells[13, 8] = "Ngày " + DateTime.Now.ToString("dd/MM/yyyy");

                    DataTable dtItem = LibQLSX.Select("select * from PaymentTableItem with(nolock) where PaymentTableID = " + PaymentTable.ID);

                    for (int i = dtItem.Rows.Count - 1; i >= 0; i--)
                    {
                        workSheet.Cells[10, 1] = i + 1;
                        workSheet.Cells[10, 2] = TextUtils.ToString(dtItem.Rows[i]["Name"]);
                        workSheet.Cells[10, 3] = TextUtils.ToString(dtItem.Rows[i]["Content"]);
                        workSheet.Cells[10, 4] = TextUtils.ToString(dtItem.Rows[i]["Code"]);
                        workSheet.Cells[10, 5] = TextUtils.ToString(dtItem.Rows[i]["Target"]);
                        workSheet.Cells[10, 6] = TextUtils.ToString(dtItem.Rows[i]["TotalCash"]);
                        workSheet.Cells[10, 7] = TextUtils.ToString(dtItem.Rows[i]["TotalCK"]);
                        workSheet.Cells[10, 8] = TextUtils.ToString(dtItem.Rows[i]["ContentCheck"]);
                        workSheet.Cells[10, 9] = TextUtils.ToString(dtItem.Rows[i]["Note"]);
                        ((Excel.Range)workSheet.Rows[10]).Insert();
                    }
                    ((Excel.Range)workSheet.Rows[9]).Delete();
                    ((Excel.Range)workSheet.Rows[9]).Delete();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (app != null)
                    {
                        app.ActiveWorkbook.Save();
                        app.Workbooks.Close();
                        app.Quit();
                    }
                }
                Process.Start(currentPath);
            }
        }
Example #19
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

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

            decimal tm = 0;
            decimal ck = 0;

            PaymentTableModel PaymentTable = new PaymentTableModel();

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

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

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

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

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

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

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

            pt.CommitTransaction();

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

            PaymentTableItemBO.Instance.Update(PaymentTable);

            loadItems();
        }
Example #20
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

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

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

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

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

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

                    item.PaymentTableID = PaymentTable.ID;

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

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

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

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

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

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

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

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

                pt.CommitTransaction();
                loadItems();
                _isSaved = true;
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
Example #21
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (grvData.SelectedRowsCount == 0)
            {
                return;
            }
            string    projectId   = TextUtils.ToString(grvData.GetFocusedRowCellValue(colID));
            string    projectCode = TextUtils.ToString(grvData.GetFocusedRowCellValue(colCode));
            DataTable dt          = TextUtils.Select("select top 1 * from ProjectDesignDate with(nolock) where ProjectCode = '" + projectCode + "'");

            ProjectDesignDateModel model = new ProjectDesignDateModel();

            if (dt.Rows.Count > 0)
            {
                model = (ProjectDesignDateModel)ProjectDesignDateBO.Instance.FindByPK(TextUtils.ToInt64(dt.Rows[0]["ID"]));
            }

            model.ProjectCode = projectCode;
            model.DateYC      = dtpStartDate.Value;
            model.DateHT      = dtpEndDate.Value;

            if (model.ID == 0)
            {
                ProjectDesignDateBO.Instance.Insert(model);
            }
            else
            {
                ProjectDesignDateBO.Instance.Update(model);
            }

            ArrayList arr = TPA.Business.ProjectBO.Instance.FindByAttribute("ProjectId", projectId);

            TPA.Model.ProjectModel p = (TPA.Model.ProjectModel)arr[0];
            p.AssemblyDeadline = (DateTime)dtpSXLRDeadline.EditValue;
            TPA.Business.ProjectBO.Instance.UpdateQLSX(p);

            MessageBox.Show("Cập nhật thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #22
0
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

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

                grvFile.FocusedRowHandle = -1;

                Require.Name         = txtName.Text.Trim().ToUpper();
                Require.Code         = txtCode.Text.Trim();
                Require.CustomerCode = TextUtils.ToString(cboCustomer.EditValue);
                Require.CustomerName = TextUtils.ToString(grvCboKhachHang.GetFocusedRowCellValue(colCboCustomerName));

                Require.Description   = txtDescription.Text;
                Require.RequireDate   = (DateTime?)dtpRequestDate.EditValue;
                Require.SolutionDate  = (DateTime?)dtpSolutionDate.EditValue;
                Require.RequirePerson = TextUtils.ToInt(cboNguoiYeuCau.EditValue);
                Require.NguoiPhuTrach = TextUtils.ToInt(cboNguoiPhuTrach.EditValue);
                Require.Priority      = cboPriority.SelectedIndex;
                Require.NguoiDaiDien  = txtNguoiDaiDien.Text.Trim();
                Require.Phone         = txtPhone.Text;
                Require.Email         = txtEmail.Text;
                Require.Cost          = TextUtils.ToDecimal(txtCost.Text);
                Require.UpdatedDate   = TextUtils.GetSystemDate();
                Require.UpdatedBy     = Global.AppUserName;

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

                //update tên cho file ipt
                DataRow[] drs = _dtFile.Select("ID = 0 or ID is null");
                if (drs.Length > 0)
                {
                    DocUtils.InitFTPTK();

                    using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang update tên cho file..."))
                    {
                        for (int i = 0; i < grvFile.RowCount; i++)
                        {
                            long id = TextUtils.ToInt64(grvFile.GetRowCellValue(i, colFileID));
                            if (id > 0)
                            {
                                continue;
                            }

                            string   name        = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileName));
                            string   extension   = Path.GetExtension(name);
                            decimal  length      = TextUtils.ToDecimal(grvFile.GetRowCellValue(i, colFileLenght));
                            string   description = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileDescription));
                            string   path        = "YeuCau/" + Require.Code + "/" + name;
                            string   createdBy   = Global.AppUserName;
                            DateTime?createdDate = DateTime.Now;

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

                            if (!DocUtils.CheckExits("YeuCau/" + Require.Code))
                            {
                                DocUtils.MakeDir("YeuCau/" + Require.Code);
                            }

                            RequireSolutionFileModel fileModel = new RequireSolutionFileModel();
                            fileModel.CreatedBy         = createdBy;
                            fileModel.CreatedDate       = createdDate;
                            fileModel.Description       = description;
                            fileModel.Extension         = extension;
                            fileModel.Length            = length;
                            fileModel.Name              = name;
                            fileModel.Path              = path;
                            fileModel.RequireSolutionID = Require.ID;
                            pt.Insert(fileModel);

                            DocUtils.UploadFile(localPath, "YeuCau/" + Require.Code);
                        }
                    }
                }

                pt.CommitTransaction();

                loadGrid();
                _isSaved = true;

                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
Example #23
0
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

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

                grvFile.FocusedRowHandle = -1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                pt.CommitTransaction();

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

                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
        bool ValidateForm()
        {
            /*if (cKnifeList.EditValue == null)
             * {
             *      MessageBox.Show("Vui lòng nhập mã dao!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
             *      return false;
             * }*/

            if (txbQuantity.Value == 0)
            {
                MessageBox.Show("Vui lòng nhập số lượng khác 0!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            if (cWorker.EditValue == null)
            {
                MessageBox.Show("Vui lòng chọn người phụ trách!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }


            if (string.IsNullOrEmpty(cKnifeList.Text))
            {
                MessageBox.Show("Vui lòng chọn loại dao!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            KnifeDetailListModel currentModel = (KnifeDetailListModel)KnifeDetailListBO.Instance.FindByPK(TextUtils.ToInt64(cKnifeList.EditValue));

            if (currentModel.CurrentATC == currentModel.ATC)
            {
                if (MessageBox.Show("Mã dao này không thể tiếp tục sử dụng! \n Bạn có muốn hủy mã dao này?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    frmKnifeDisposed frm = new frmKnifeDisposed();
                    frm.knifeID = currentModel.ID;
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        knifeProcessedList = new KnifeProcessedListModel();
                        ClearFormData();
                        LoadData();
                    }
                }
                return(false);
            }

            if (currentModel.CurrentSTD == currentModel.STD)
            {
                if (MessageBox.Show("Mã dao này cần được mài trước khi sử dụng! \n Bạn có muốn mài mã dao này ngay bây giờ?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    // Mai dao
                    frmKnifeSharpen frm = new frmKnifeSharpen();
                    frm.knifeID = TextUtils.ToInt(cKnifeList.EditValue);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        knifeProcessedList = new KnifeProcessedListModel();
                        ClearFormData();
                        LoadData();
                    }
                }
                return(false);
            }
            return(true);
        }