Example #1
0
        private void btnSaveAndClose_Click(object sender, EventArgs e)
        {
            Part.HsCode      = txtHScode.Text.Trim();
            Part.Description = txtDescription.Text.Trim();
            Part.ImportTax   = TextUtils.ToDecimal(txtImportTax.EditValue);
            Part.Price       = TextUtils.ToDecimal(txtPrice.EditValue);
            if (_priceOld != Part.Price)
            {
                Part.UpdatedPriceDate = DateTime.Now;

                TPA.Model.PartsPriceAuditModel p = new TPA.Model.PartsPriceAuditModel();
                p.Price        = Part.Price;
                p.PartsCode    = Part.PartsCode;
                p.ProjectCode  = "";
                p.PType        = 4;
                p.PartsID      = p.PartsID;
                p.UpdatedDate  = DateTime.Now;
                p.CreatedDate  = DateTime.Now;
                p.DeliveryTime = 1;
                TPA.Business.PartsPriceAuditBO.Instance.Insert(p);
            }
            PartsBO.Instance.UpdateQLSX(Part);

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

            this.Close();
        }
Example #2
0
        private void btnAddVT_Click(object sender, EventArgs e)
        {
            frmListMaterial frm = new frmListMaterial();

            frm.dtAll = _dtMaterial.Copy();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                _dtMaterial = frm.dtAll;
                foreach (DataRow row in _dtMaterial.Rows)
                {
                    string    code = TextUtils.ToString(row["Code"]);
                    DataRow[] drs  = _dtListMaterial.Select("Code = '" + code + "'");
                    if (drs.Length == 0)
                    {
                        DataRow dr = _dtListMaterial.NewRow();
                        dr["Code"]   = TextUtils.ToString(row["Code"]);
                        dr["Name"]   = TextUtils.ToString(row["Name"]);
                        dr["Hang"]   = TextUtils.ToString(row["Hang"]);
                        dr["Unit"]   = TextUtils.ToString(row["Unit"]);
                        dr["Qty"]    = TextUtils.ToDecimal(row["Qty"]);
                        dr["TonKho"] = TextUtils.ToDecimal(row["TonKho"]);
                        _dtListMaterial.Rows.Add(dr);
                    }
                }
                //grdVT.DataSource = _dtListMaterial;
            }
        }
Example #3
0
        void loadData()
        {
            string projectId = TextUtils.ToString(cboProject.EditValue);

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

            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang load dữ liệu..."))
            {
                string    sql = "spGetOrderOfProject '" + projectId + "'";
                DataTable dt  = LibQLSX.Select(sql);
                dt.Columns.Add("ChenhLech", typeof(decimal));
                foreach (DataRow row in dt.Rows)
                {
                    decimal totalVAT  = TextUtils.ToDecimal(row["TotalVAT"]);
                    string  orderCode = TextUtils.ToString(row["OrderCode"]);

                    decimal totalInvoice = 0;
                    string  sql1         = "select sum(T_XNTC.C_PSNO) FROM T_XNTC INNER JOIN T_DM_VUVIEC ON T_XNTC.FK_VUVIEC = T_DM_VUVIEC.PK_ID" +
                                           " WHERE (T_DM_VUVIEC.C_MA = '" + orderCode + "') AND (T_XNTC.FK_TKNO LIKE '133%')";
                    totalInvoice = TextUtils.ToDecimal(LibIE.ExcuteScalar(sql1));

                    row["ChenhLech"] = totalVAT - totalInvoice;
                }
                grdData.DataSource = dt;
            }
        }
Example #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (ProductWorkingOld.ID > 0 &&
         ProductWorkingOld.ID == ProductWorking.ID &&
         ProductWorkingOld.ProductID == ProductID &&
         ProductWorkingOld.ProductStepID == TextUtils.ToInt(cboStep.EditValue) &&
         ProductWorkingOld.WorkingName == txtName.Text.Trim() &&
         ProductWorkingOld.SortOrder == (int)txtSortOrder.Value &&
         ProductWorkingOld.Unit == txtUnit.Text.Trim() &&
         ProductWorkingOld.IsHidden == chkIsShow.Checked &&
         ProductWorkingOld.ValueType == cboValueType.SelectedIndex &&
         ProductWorkingOld.MaxValue == TextUtils.ToDecimal(txtMax.Value) &&
         ProductWorkingOld.MinValue == TextUtils.ToDecimal(txtMin.Value) &&
         ProductWorkingOld.CheckValueType == cboCheckValueType.SelectedIndex &&
         ProductWorkingOld.ProductStepCode == cboStep.Text.Trim() &&
         ProductWorkingOld.PeriodValue == txtPeriodValue.Text.Trim())
     {
         this.DialogResult = DialogResult.OK;
     }
     else
     {
         if (saveData())
         {
             this.DialogResult = DialogResult.OK;
         }
     }
 }
Example #5
0
        private void btnImportPrice_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = false;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                DataTable dtPrice = TextUtils.ExcelToDatatableNoHeader(ofd.FileName, "Sheet1");
                for (int i = 0; i < grvData.RowCount; i++)
                {
                    string    partsCode  = TextUtils.ToString(grvData.GetRowCellValue(i, colCode));
                    decimal   giaGanNhat = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colPriceGN));
                    decimal   qty        = TextUtils.ToDecimal(grvData.GetRowCellValue(i, colTotalBuy));
                    DataRow[] drs        = dtPrice.Select("F3 = '" + partsCode + "'");
                    if (drs.Length > 0)
                    {
                        decimal currentPrice = TextUtils.ToDecimal(drs[0]["F7"]);
                        grvData.SetRowCellValue(i, colPrice, currentPrice);
                        grvData.SetRowCellValue(i, colChenhLech, currentPrice - giaGanNhat);
                        //grvData.SetRowCellValue(i, colChenhLech, currentPrice - giaGanNhat);
                        grvData.SetRowCellValue(i, colTotalChenhLech, qty * (currentPrice - giaGanNhat));
                    }
                }
            }
        }
Example #6
0
        DataTable loadPartOfYCMVT(string proposalCode)
        {
            DataTable Source = LibQLSX.Select("spGetPartWithYCMVT_All '" + proposalCode + "'");
            DataTable dt     = Source.Copy();

            dt.Rows.Clear();
            foreach (DataRow row in Source.Rows)
            {
                string  code           = TextUtils.ToString(row["PartsCode"]);
                decimal totalBuy       = TextUtils.ToDecimal(row["TotalBuy"]);
                decimal total          = TextUtils.ToDecimal(row["Total"]);
                decimal totalInventory = TextUtils.ToDecimal(row["TotalInventory"]);

                DataRow[] drs = dt.Select("PartsCode = '" + code + "'");
                if (drs.Length == 0)
                {
                    dt.ImportRow(row);
                }
                else
                {
                    drs[0]["TotalBuy"]       = TextUtils.ToDecimal(drs[0]["TotalBuy"]) + totalBuy;
                    drs[0]["Total"]          = TextUtils.ToDecimal(drs[0]["Total"]) + total;
                    drs[0]["TotalInventory"] = TextUtils.ToDecimal(drs[0]["TotalInventory"]) + totalInventory;
                }
            }
            return(dt);
        }
Example #7
0
        void splitGearCheck()
        {
            ArrayList lst = ProductBO.Instance.FindAll();

            for (int i = 0; i < lst.Count; i++)
            {
                ProductModel model = (ProductModel)lst[i];
                string       b     = model.LucCheckGear;
                if (!string.IsNullOrEmpty(b))
                {
                    string[] numbers = Regex.Split(b, @"[^0-9\.]+");
                    if (numbers.Length > 1)
                    {
                        model.LucCheckGearMin = TextUtils.ToDecimal(numbers[0]);
                        model.LucCheckGearMax = TextUtils.ToDecimal(numbers[1]);
                    }
                }

                b = model.LucCheckGearMotor;
                if (!string.IsNullOrEmpty(b))
                {
                    string[] numbers = Regex.Split(b, @"[^0-9\.]+");
                    if (numbers.Length > 1)
                    {
                        model.LucCheckGearMotorMin = TextUtils.ToDecimal(numbers[0]);
                        model.LucCheckGearMotorMax = TextUtils.ToDecimal(numbers[1]);
                    }
                }

                ProductBO.Instance.Update(model);
            }
        }
Example #8
0
 private void btnLoadPrice_Click(object sender, EventArgs e)
 {
     using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát", "Đang load giá..."))
     {
         foreach (DataRow item in _dtItem.Rows)
         {
             string    partCode     = TextUtils.ToString(item["PartsCode"]);
             string    sql1         = "exec spGetPriceOfPart '" + partCode + "'";
             DataTable dtOrderPrice = LibQLSX.Select(sql1);
             if (dtOrderPrice.Rows.Count > 0)
             {
                 item["PriceDM"]        = TextUtils.ToDecimal(dtOrderPrice.Rows[0]["Price"]);
                 item["DeliveryTimeDM"] = TextUtils.ToInt(dtOrderPrice.Rows[0]["DeliveryTime"]);
             }
             else
             {
                 item["PriceDM"]        = TextUtils.ToDecimal(item["Price"]);
                 item["DeliveryTimeDM"] = TextUtils.ToInt(item["DeliveryTime"]);
             }
             //item["ChenhLech"] = TextUtils.ToDecimal(item["Price"]) - TextUtils.ToDecimal(item["PriceDM"]);
             //item["TotalChenhLech"] = TextUtils.ToDecimal(item["TotalBuy"]) * TextUtils.ToDecimal(item["ChenhLech"]);
         }
         grdData.DataSource = _dtItem;
     }
 }
Example #9
0
        void updateCostProductLink()
        {
            for (int i = 0; i < grvData.RowCount; i++)
            {
                //int costID = TextUtils.ToInt(grvData.GetRowCellValue(i, "F2"));
                //if (costID == 0) continue;
                //for (int j = 1; j < 14; j++)
                //{
                //    decimal value = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F" + (2 + j)));
                //    ArrayList arr = C_CostProductGroupLinkBO.Instance.FindByExpression(new TPA.Utils.Expression("C_CostID", costID).And(new TPA.Utils.Expression("C_ProductGroupID", j)));
                //    C_CostProductGroupLinkModel m = (C_CostProductGroupLinkModel)arr[0];
                //    m.ValuePercent = value;
                //    C_CostProductGroupLinkBO.Instance.Update(m);
                //}

                int linkID = TextUtils.ToInt(grvData.GetRowCellValue(i, "F1"));
                if (linkID == 0)
                {
                    continue;
                }
                C_CostProductGroupLinkModel arr = (C_CostProductGroupLinkModel)C_CostProductGroupLinkBO.Instance.FindByPK(linkID);
                //arr.IsDirectCost = TextUtils.ToInt(grvData.GetRowCellValue(i, "F10"));
                arr.IsFix        = TextUtils.ToInt(grvData.GetRowCellValue(i, "F9"));
                arr.NumberDay    = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F8"));
                arr.PersonNumber = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F6"));
                arr.VtuPercent   = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F7"));
                C_CostProductGroupLinkBO.Instance.Update(arr);
            }
            MessageBox.Show("OK");
        }
Example #10
0
 void GhiGia()
 {
     for (int i = 0; i < grvData.RowCount; i++)
     {
         if (i == 0)
         {
             continue;
         }
         if (grvData.GetRowCellValue(i, "F1") == null)
         {
             continue;
         }
         string code = grvData.GetRowCellValue(i, "F1").ToString();
         if (code == "")
         {
             continue;
         }
         try
         {
             MaterialModel material = (MaterialModel)MaterialBO.Instance.FindByAttribute("Code", code)[0];
             material.PriceTemp          = TextUtils.ToDecimal(grvData.GetRowCellValue(i, "F5") == null ? "0" : grvData.GetRowCellValue(i, "F5"));
             material.DeliveryPeriodTemp = grvData.GetRowCellValue(i, "F6") == null ? "" : grvData.GetRowCellValue(i, "F6").ToString();
             MaterialBO.Instance.Update(material);
         }
         catch (Exception)
         {
         }
     }
     MessageBox.Show("Thành công!");
 }
Example #11
0
        void loadText()
        {
            string[] paraName  = new string[2];
            object[] paraValue = new object[2];
            paraName[0] = "@Year"; paraValue[0] = 0;
            paraName[1] = "@QuotationID"; paraValue[1] = Quotation.ID;

            DataTable dtQuotation = C_CostBO.Instance.LoadDataFromSP("spReportQuotationSX", "Source", paraName, paraValue);

            if (dtQuotation.Rows.Count > 0)
            {
                txtTotalHD.EditValue  = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalHD"]);
                txtTotalTPA.EditValue = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalTPA"]);
                //txtTotalTPA_PreVAT.EditValue = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalTPA_PreVAT"]);
                //txtTotalVAT.EditValue = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalVAT"]);
                txtTotalVT.EditValue = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalVT"]);

                txtTotalNC.EditValue    = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalNC"]);
                txtTotalPB.EditValue    = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalPB"]);
                txtTotalDP.EditValue    = Quotation.TotalDP_SX;
                txtTotalVC.EditValue    = Quotation.TotalCPVCHB_C13;
                txtTotalBX.EditValue    = Quotation.TotalBXHB_C52;
                txtTotalDiLai.EditValue = Quotation.TotalDiLai;

                //txtTotalNC_KD.EditValue = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalNC_KD"]);
                //txtTotalReal.EditValue = TextUtils.ToDecimal(txtTotalHD.EditValue) - TextUtils.ToDecimal(txtTotalVC.EditValue);
                txtTotalProfit.EditValue = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalProfit"]);
                //txtTotalProfitQD.EditValue = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalProfitQD"]);
            }
        }
Example #12
0
        void save()
        {
            //grvLink.ClearColumnsFilter(); * (1 + 0.3M * (item.Qty >= 2 ? item.Qty - 1 : 0)) / item.Qty colC_QuotationDetailID
            grvLink.FocusedRowHandle = -1;
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang xử lý..."))
            {
                for (int i = 0; i < grvLink.RowCount; i++)
                {
                    int id = TextUtils.ToInt(grvLink.GetRowCellValue(i, colID));
                    if (id == 0)
                    {
                        return;
                    }
                    decimal pricePerDay = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPricePerDay));
                    int     costID      = TextUtils.ToInt(grvLink.GetRowCellValue(i, colC_CostID));
                    decimal qty         = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colQty));

                    C_CostQuotationItemLinkModel link = (C_CostQuotationItemLinkModel)C_CostQuotationItemLinkBO.Instance.FindByPK(id);
                    link.NumberDay    = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colNumberDay));
                    link.PersonNumber = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPersonNumber));
                    link.TotalR       = link.NumberDay * link.PersonNumber;
                    if (costID == 61)//nhân công thiết kế
                    {
                        //int quotationDetailID = TextUtils.ToInt(grvLink.GetRowCellValue(i, colC_QuotationDetailID));
                        //C_QuotationDetailModel item = (C_QuotationDetailModel)C_QuotationDetailBO.Instance.FindByPK(quotationDetailID);
                        link.TotalR *= (1 + 0.3M * (qty - 1)) / qty;
                    }
                    link.Price = link.TotalR * pricePerDay;
                    C_CostQuotationItemLinkBO.Instance.Update(link);
                }
                IsSaved = true;
            }
            MessageBox.Show("Lưu trữ thành công.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #13
0
        private void txtVAT_EditValueChanged(object sender, EventArgs e)
        {
            decimal total = (TextUtils.ToDecimal(txtTotalTH.EditValue) + TextUtils.ToDecimal(txtDiffCost.EditValue) + TextUtils.ToDecimal(txtDeliveryCost.EditValue));

            total = total + (TextUtils.ToDecimal(txtVAT.EditValue) * total / 100);
            txtTotal.EditValue = total;
        }
Example #14
0
 /// <summary>
 /// Check_OK_NG
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void grvData_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (e.Column == colClockDial12 || e.Column == colVibrationMax1 || e.Column == colVibrationMin1)
     {
         if (TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colClockDial12)) <= Decimal.Parse(txtSlitMax.Text.ToString()) && TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colVibrationMax1)) <= Decimal.Parse(txtVibrateMaxT.Text.ToString()) && TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colVibrationMin1)) <= Decimal.Parse(txtVibrateMaxN.Text.ToString()))
         {
             grvData.SetRowCellValue(e.RowHandle, colResult1, "OK");
         }
         else
         {
             grvData.SetRowCellValue(e.RowHandle, colResult1, "NG");
         }
         return;
     }
     if (e.Column == colVibrate21 || e.Column == colVibrate22 || e.Column == colVibrate23 || e.Column == colClockDial22 || e.Column == colVibrationMax2 || e.Column == colVibrationMin2)
     {
         if (TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colClockDial22)) <= Decimal.Parse(txtSlitMax.Text.ToString()) && TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colVibrationMax2)) <= Decimal.Parse(txtVibrateMaxT.Text.ToString()) && TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colVibrationMin2)) <= Decimal.Parse(txtVibrateMaxN.Text.ToString()) && TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colVibrate21)) <= 0.01M && TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colVibrate22)) <= 0.02M && TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colVibrate23)) <= 0.01M)
         {
             grvData.SetRowCellValue(e.RowHandle, colResult2, "OK");
         }
         else
         {
             grvData.SetRowCellValue(e.RowHandle, colResult2, "NG");
         }
         return;
     }
 }
Example #15
0
        private void cboUser_EditValueChanged(object sender, EventArgs e)
        {
            if (TextUtils.ToString(grvCboUser.GetFocusedRowCellValue(colUserCode)) == "")
            {
                return;
            }

            _type = 2;

            //cboUser.EditValue = null;
            cboSupplier.EditValue = null;
            cboOrder.EditValue    = null;
            //cboNguoiPhuTrach.EditValue = null;

            txtCode.Text               = TextUtils.ToString(grvCboUser.GetFocusedRowCellValue(colUserCode));
            txtName.Text               = TextUtils.ToString(grvCboUser.GetFocusedRowCellValue(colFullName));
            txtTotalTH.EditValue       = 0;
            txtDiffCost.EditValue      = 0;
            txtDeliveryCost.EditValue  = 0;
            txtTotal.EditValue         = 0;
            txtPercentPay.Text         = "100";
            chkTM.Checked              = true;
            txtTM.EditValue            = TextUtils.ToDecimal(txtTotal.EditValue) * TextUtils.ToDecimal(txtPercentPay.EditValue) / 100;
            txtCK.EditValue            = 0;
            txtTarget.Text             = "";
            txtTotalTransfer.EditValue = 0;
            cboNguoiPhuTrach.EditValue = TextUtils.ToString(grvCboUser.GetFocusedRowCellValue(colUserID));
        }
Example #16
0
        void calculateCost()
        {
            if (chkTM.Checked)
            {
                txtTM.EditValue = TextUtils.ToDecimal(txtPercentPay.EditValue) * TextUtils.ToDecimal(txtTotal.EditValue) / 100;
                txtCK.EditValue = 0;
            }
            else
            {
                txtCK.EditValue = TextUtils.ToDecimal(txtPercentPay.EditValue) * TextUtils.ToDecimal(txtTotal.EditValue) / 100;
                txtTM.EditValue = 0;
            }

            //decimal diff = TextUtils.ToDecimal(txtTotal.EditValue) - (TextUtils.ToDecimal(txtTM.EditValue)
            //    + TextUtils.ToDecimal(txtCK.EditValue) + TextUtils.ToDecimal(txtTotalTransfer.EditValue));

            //if (diff > 0)
            //{
            //    txtContent.Text = "Thanh toán " + txtPercentPay.Text + "% tiền hàng";
            //}
            //else
            //{
            //    txtContent.Text = "Thanh toán nốt tiền hàng";
            //}
        }
Example #17
0
        private void grvLink_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column == colNumberDay || e.Column == colPersonNumber || e.Column == colNCType)
            {
                decimal numberDay    = TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colNumberDay));
                decimal personNumber = TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colPersonNumber));
                decimal qty          = TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colQty));
                decimal pricePerDay  = 0;// TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colPricePerDay));

                if (e.Column == colNCType)
                {
                    string ncType = TextUtils.ToString(grvLink.GetFocusedRowCellValue(colNCType));
                    int    costID = TextUtils.ToInt(grvLink.GetFocusedRowCellValue(colC_CostID));
                    string sql    = "select Price from C_CostNCType where C_CostID = " + costID + " and CostNCType = '" + ncType + "'";

                    pricePerDay = TextUtils.ToDecimal(LibQLSX.ExcuteScalar(sql));
                }
                else
                {
                    pricePerDay = TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colPricePerDay));
                }

                grvLink.SetFocusedRowCellValue(colPricePerDay, pricePerDay);

                decimal price = numberDay * personNumber * pricePerDay;

                grvLink.SetFocusedRowCellValue(colPrice, price);
                grvLink.SetFocusedRowCellValue(colTongTien, qty * price);
            }
        }
Example #18
0
        void save()
        {
            //grvLink.ClearColumnsFilter(); * (1 + 0.3M * (item.Qty >= 2 ? item.Qty - 1 : 0)) / item.Qty colC_QuotationDetailID
            grvLink.ExpandAllGroups();
            grvLink.FocusedRowHandle = -1;
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang xử lý..."))
            {
                for (int i = 0; i < grvLink.RowCount; i++)
                {
                    int id = TextUtils.ToInt(grvLink.GetRowCellValue(i, colID));
                    if (id == 0)
                    {
                        return;
                    }
                    decimal pricePerDay = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPricePerDay));

                    C_CostQuotationItemLinkNewModel link = (C_CostQuotationItemLinkNewModel)C_CostQuotationItemLinkNewBO.Instance.FindByPK(id);
                    link.NumberDay    = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colNumberDay));
                    link.PersonNumber = TextUtils.ToDecimal(grvLink.GetRowCellValue(i, colPersonNumber));
                    link.TotalR       = link.NumberDay * link.PersonNumber;
                    link.Price        = link.TotalR * pricePerDay;
                    link.IsDirect     = 1;
                    link.CostNCType   = TextUtils.ToString(grvLink.GetRowCellValue(i, colNCType));
                    C_CostQuotationItemLinkNewBO.Instance.Update(link);
                }
                IsSaved = true;
            }
            MessageBox.Show("Lưu trữ thành công.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #19
0
 /// <summary>
 /// LoadDataInTextBox
 /// </summary>
 private void LoadData()
 {
     if (!string.IsNullOrEmpty(txtOrderNo.Text.Trim()))
     {
         try
         {
             DataTable dt = TextUtils.LoadDataFromSP("spGetGearInfo_ByOrderCode", "A"
                                                     , new string[1] {
                 "@OrderCode"
             }
                                                     , new object[1] {
                 txtOrderNo.Text.Trim()
             });
             Qty                 = TextUtils.ToInt(dt.Rows[0]["Qty"]);
             txtQty.Text         = Qty.ToString("n0");
             txtLAP.Text         = TextUtils.ToString(dt.Rows[0]["ProductCode"]);
             txtSlitMax.Text     = TextUtils.ToDecimal(dt.Rows[0]["SlitMax"]).ToString("n3");
             txtSlitMin.Text     = TextUtils.ToDecimal(dt.Rows[0]["SlitMin"]).ToString("n3");
             txtVibrateMaxT.Text = TextUtils.ToDecimal(dt.Rows[0]["VibrateMax"]).ToString("n3");
             txtVibrateMaxN.Text = txtVibrateMaxT.Text;
             txtVibrateMinT.Text = TextUtils.ToDecimal(dt.Rows[0]["VibrateMin"]).ToString("n3");
             txtVibrateMinN.Text = txtVibrateMinT.Text;
             SlitMax             = Decimal.Parse(txtSlitMax.Text.ToString());
         }
         catch (Exception)
         {
             MessageBox.Show("OrderNo is not correct");
         }
     }
 }
Example #20
0
        void addRequestItem(string requestCode)
        {
            string sql = "";

            //sql = "select * from vRequirePartFull with(nolock) where RequestCode ='" + requestCode + "'";
            sql = "select *,(Price * TotalBuy) as TotalPrice from vRequestMaterial with(nolock) where RequestCode ='" + requestCode + "'";

            DataTable dt = LibQLSX.Select(sql);

            //DataRow[] drs = dt.Select("Price = 0 or Price is null");
            foreach (DataRow r in dt.Rows)
            {
                //string sqlM = "SELECT top 1 Price FROM  vGetPriceOfPart with(nolock)"
                //            + " WHERE Price > 1 AND replace(replace([PartsCode],'/','#'),')','#') = '" + TextUtils.ToString(r["PartsCode"]) + "'"
                //            + " ORDER BY DateAboutF DESC";
                //DataTable dtOrderPriceM = LibQLSX.Select(sqlM);

                string    sqlM          = "exec spGetPriceOfPart '" + TextUtils.ToString(r["PartsCode"]) + "'";
                DataTable dtOrderPriceM = LibQLSX.Select(sqlM);
                if (dtOrderPriceM.Rows.Count > 0)
                {
                    r["Price"]      = TextUtils.ToDecimal(dtOrderPriceM.Rows[0][0]);
                    r["TotalPrice"] = TextUtils.ToDecimal(r["Price"]) * TextUtils.ToDecimal(r["TotalBuy"]);
                }
            }
            grdParts.DataSource = dt;
        }
Example #21
0
 private void grvLink_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
 {
     if (TextUtils.ToDecimal(grvLink.GetRowCellValue(e.RowHandle, colLinkTyLe)) > 0)
     {
         e.Appearance.BackColor = Color.GreenYellow;
     }
 }
Example #22
0
        private void grvData_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            decimal qty = TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colQty));
            decimal vat = TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colVAT)) / 100;

            decimal priceHD     = TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colPriceHD));
            decimal priceTPA    = TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colPriceTPA));
            decimal priceReal   = TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colPriceReal));
            decimal priceVT     = TextUtils.ToDecimal(grvData.GetRowCellValue(e.RowHandle, colPriceDT));
            string  priceType   = TextUtils.ToString(grvData.GetRowCellValue(e.RowHandle, colPriceType));
            int     costGroupID = TextUtils.ToInt(grvData.GetRowCellValue(e.RowHandle, colCostGroupID));

            bool isChange = false;

            if (e.Column == colQty)
            {
                grvData.SetRowCellValue(e.RowHandle, colTotalVT, qty * priceVT);
                grvData.SetRowCellValue(e.RowHandle, colTotalHD, qty * priceHD);
                grvData.SetRowCellValue(e.RowHandle, colTotalTPA, qty * priceTPA);
                grvData.SetRowCellValue(e.RowHandle, colTotalReal, qty * priceReal);
                isChange = true;
            }

            if (e.Column == colVAT)
            {
                grvData.SetRowCellValue(e.RowHandle, colPriceHDnoVAT, priceHD * (1 - vat));
                grvData.SetRowCellValue(e.RowHandle, colTotalHDnoVat, qty * (priceHD * (1 - vat)));
                isChange = true;
            }

            if (e.Column == colPriceType || e.Column == colPriceDT || e.Column == colCostGroupID)
            {
                decimal costSX = GetCostSX(costGroupID, priceVT);
                decimal costTM = GetCostTM(costGroupID, priceVT);
                if (priceType.ToUpper() == "SX")
                {
                    grvData.SetRowCellValue(e.RowHandle, colPriceTPA, costSX);
                    grvData.SetRowCellValue(e.RowHandle, colTotalTPA, qty * costSX);
                }
                else
                {
                    grvData.SetRowCellValue(e.RowHandle, colPriceTPA, costTM);
                    grvData.SetRowCellValue(e.RowHandle, colTotalTPA, qty * costTM);
                }
            }

            if (e.Column == colPriceHD)
            {
                grvData.SetRowCellValue(e.RowHandle, colPriceHDnoVAT, priceHD * (1 - vat));
                grvData.SetRowCellValue(e.RowHandle, colTotalHDnoVat, qty * (priceHD * (1 - vat)));
                grvData.SetRowCellValue(e.RowHandle, colTotalHD, qty * priceHD);
                isChange = true;
            }

            if (isChange)
            {
                loadRealPrice();
            }
        }
Example #23
0
        void loadCostDA()
        {
            decimal totalHD = TextUtils.ToDecimal(txtTotalHD.EditValue);

            _dtCostQuotationLink = LibQLSX.Select("select *,TyLe = (Case when " + totalHD + " = 0 then 0 else CAST (Total/" + totalHD + " * 100 as decimal(18,4)) end) from vC_CostQuotationLink where C_QuotationID = "
                                                  + thisQuotation.ID);
            grdLink.DataSource = _dtCostQuotationLink;
        }
Example #24
0
        private void cboCostGroup_EditValueChanged(object sender, EventArgs e)
        {
            lblTradePercent.Text = TextUtils.ToDecimal(grvCostGroup.GetFocusedRowCellValue(colPercentTrade)) == 0 ? "0%" : grvCostGroup.GetFocusedRowCellValue(colPercentTrade).ToString() + "%";
            lblUserPercent.Text  = TextUtils.ToDecimal(grvCostGroup.GetFocusedRowCellValue(colPercentUser)) == 0 ? "0%" : grvCostGroup.GetFocusedRowCellValue(colPercentUser).ToString() + "%";
            lblVAT.Text          = TextUtils.ToDecimal(grvCostGroup.GetFocusedRowCellValue(colVAT)) == 0 ? "0%" : grvCostGroup.GetFocusedRowCellValue(colVAT).ToString() + "%";

            loadCost(TextUtils.ToInt(cboCostGroup.EditValue));
        }
Example #25
0
        private void grvHistory_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            GridView             view  = sender as GridView;
            MaterialHistoryModel model = (MaterialHistoryModel)MaterialHistoryBO.Instance.FindByPK(TextUtils.ToInt(view.GetRowCellValue(e.RowHandle, colID)));

            model.Qty = TextUtils.ToDecimal(view.GetRowCellValue(e.RowHandle, colQty));
            MaterialHistoryBO.Instance.Update(model);
        }
Example #26
0
        private void treeData_NodeCellStyle(object sender, GetCustomNodeCellStyleEventArgs e)
        {
            //if (_isStyle) return;

            decimal percentVT = TextUtils.ToDecimal(e.Node.GetValue(colPercentVT));
            decimal qty       = TextUtils.ToDecimal(e.Node.GetValue(colQty));

            if (e.Column == colPercentExport || e.Column == colPercentVT)
            {
                decimal percentExport = TextUtils.ToDecimal(e.Node.GetValue(colPercentExport));
                if (percentVT >= 100 && percentExport >= 100)
                {
                    e.Appearance.BackColor = Color.GreenYellow;
                }
                if (percentVT >= 100 && percentExport < 100)
                {
                    e.Appearance.BackColor = Color.Yellow;
                }
                //if (percentVT == 0 && qty == 0)
                //{
                //    e.Appearance.BackColor = Color.MediumTurquoise;
                //}
            }

            if (e.Column == colDateAboutE && percentVT < 100)
            {
                if (qty == 0)
                {
                    return;
                }

                if (TextUtils.ToDate3(e.Node.GetValue(colDateAboutE)).Date > TextUtils.ToDate3(dtpSXLRDeadline.EditValue).Date)
                {
                    e.Appearance.BackColor = Color.Red;
                }
                else
                {
                    if (TextUtils.ToInt(e.Node.GetValue(colTotalDateAboutENull)) > 0)
                    {
                        e.Appearance.BackColor = Color.Orange;
                    }
                }
            }

            if (e.Column == colIN || e.Column == colCNC || e.Column == colPCB || e.Column == colGCAL || e.Column == colLR)
            {
                string date = TextUtils.ToString(e.Node.GetValue(e.Column));
                if (date.Contains("-"))
                {
                    DateTime dateDK = TextUtils.ToDate(date);
                    if (DateTime.Now.Date > dateDK.Date)
                    {
                        e.Appearance.BackColor = Color.Red;
                    }
                }
            }
            //_isStyle = true;
        }
Example #27
0
 /// <summary>
 /// check Color in dataGridview when load data from DataBase
 /// hàm chỉ được thực hiện khi load dữ liệu từ dataBase lên form
 /// </summary>
 private void checkColor()
 {
     for (int i = 0; i < _qty; i++)
     {
         if (TextUtils.ToString(grvData.Rows[i].Cells[colResult1.Name].Value).ToUpper() == "OK")
         {
             grvData.Rows[i].Cells[colResult1.Name].Style.BackColor = Color.Green;
         }
         if (TextUtils.ToString(grvData.Rows[i].Cells[colResult1.Name].Value).ToUpper() == "NG")
         {
             grvData.Rows[i].Cells[colResult1.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToString(grvData.Rows[i].Cells[colResult2.Name].Value).ToUpper() == "OK")
         {
             grvData.Rows[i].Cells[colResult2.Name].Style.BackColor = Color.Green;
         }
         if (TextUtils.ToString(grvData.Rows[i].Cells[colResult2.Name].Value).ToUpper() == "NG")
         {
             grvData.Rows[i].Cells[colResult2.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colClockDial12.Name].Value) > TextUtils.ToDecimal(txtSlitMax.Text.ToString()))
         {
             grvData.Rows[i].Cells[colClockDial12.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrationForward1.Name].Value) > TextUtils.ToDecimal(txtVibrateMaxT.Text.ToString()))
         {
             grvData.Rows[i].Cells[colVibrationForward1.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrationReverse1.Name].Value) > TextUtils.ToDecimal(txtVibrateMaxN.Text.ToString()))
         {
             grvData.Rows[i].Cells[colVibrationReverse1.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colClockDial22.Name].Value) > TextUtils.ToDecimal(txtSlitMax.Text.ToString()))
         {
             grvData.Rows[i].Cells[colClockDial22.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrationForward2.Name].Value) > TextUtils.ToDecimal(txtVibrateMaxT.Text.ToString()))
         {
             grvData.Rows[i].Cells[colVibrationForward2.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrationReverse2.Name].Value) > TextUtils.ToDecimal(txtVibrateMaxN.Text.ToString()))
         {
             grvData.Rows[i].Cells[colVibrationReverse2.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate21.Name].Value) > 0.01M)
         {
             grvData.Rows[i].Cells[colVibrate21.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate22.Name].Value) > 0.02M)
         {
             grvData.Rows[i].Cells[colVibrate22.Name].Style.BackColor = tempColor;
         }
         if (TextUtils.ToDecimal(grvData.Rows[i].Cells[colVibrate23.Name].Value) > 0.01M)
         {
             grvData.Rows[i].Cells[colVibrate23.Name].Style.BackColor = tempColor;
         }
     }
 }
Example #28
0
 private void grvLink_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (e.Column == colQty || e.Column == colPrice)
     {
         decimal qty   = TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colQty));
         decimal price = TextUtils.ToDecimal(grvLink.GetFocusedRowCellValue(colPrice));
         grvLink.SetFocusedRowCellValue(colTotal, qty * price);
     }
 }
Example #29
0
 private void btnDeleteVT_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn xóa vật tư này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         grvVT.DeleteSelectedRows();
         txtDateM.Text  = TextUtils.ToDecimal(colMaTime.SummaryItem.SummaryValue).ToString("n0");
         txtTotalM.Text = TextUtils.ToDecimal(colMaTotal.SummaryItem.SummaryValue).ToString("n0");
     }
 }
Example #30
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();
            }
        }