Пример #1
0
 private void frmDirectCost_Load(object sender, EventArgs e)
 {
     model = (C_QuotationModel)C_QuotationBO.Instance.FindByPK(C_QuotationID);
     //btnSave.en
     btnResetAll.Enabled = btnSave.Enabled = btnSaveAndClose.Enabled = resetToolStripMenuItem.Enabled = !model.IsApproved;
     loadData();
 }
        private void cboProject_EditValueChanged(object sender, EventArgs e)
        {
            int quotationID = TextUtils.ToInt(cboBaoGia.EditValue);
            //if (quotationID == 0) return;

            C_QuotationModel thisQuotation = (C_QuotationModel)C_QuotationBO.Instance.FindByPK(quotationID);

            string[] paraName  = new string[1];
            object[] paraValue = new object[1];
            paraName[0] = "@QuotationID"; paraValue[0] = quotationID;

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

            if (dtQuotation.Rows.Count > 0)
            {
                thisQuotation.TotalHD = TextUtils.ToDecimal(dtQuotation.Rows[0]["TotalHD"]);
            }

            DataTable dt = LibQLSX.Select("spReportQuotationWithProductGroup " + quotationID);

            DataColumn colTotalCustomer = new DataColumn();

            colTotalCustomer.DataType   = System.Type.GetType("System.Decimal");
            colTotalCustomer.ColumnName = "TotalCustomer";
            colTotalCustomer.Expression = thisQuotation.TotalCustomer + " * TotalHD / " + thisQuotation.TotalHD;
            dt.Columns.Add(colTotalCustomer);

            DataColumn colCustomerValue = new DataColumn();

            colCustomerValue.DataType   = System.Type.GetType("System.Decimal");
            colCustomerValue.ColumnName = "CustomerValue";
            colCustomerValue.Expression = "TotalHD * " + (thisQuotation.CustomerPercent / 100) + " + TotalHD / " + thisQuotation.TotalHD + " * " + thisQuotation.CustomerCash;
            dt.Columns.Add(colCustomerValue);

            DataColumn colTotalReal = new DataColumn();

            colTotalReal.DataType   = System.Type.GetType("System.Decimal");
            colTotalReal.ColumnName = "TotalReal";
            colTotalReal.Expression = "TotalHD - CustomerValue";
            dt.Columns.Add(colTotalReal);

            DataColumn colTotalBX = new DataColumn();

            colTotalBX.DataType   = System.Type.GetType("System.Decimal");
            colTotalBX.ColumnName = "TotalBX";
            colTotalBX.Expression = "CustomerValue * 0.15";
            dt.Columns.Add(colTotalBX);

            DataColumn colTotalProfit = new DataColumn();

            colTotalProfit.DataType   = System.Type.GetType("System.Decimal");
            colTotalProfit.ColumnName = "TotalProfit";
            colTotalProfit.Expression = "TotalReal - TotalVAT - TotalCustomer - TotalNC - TotalVT - TotalPB - TotalBX";
            dt.Columns.Add(colTotalProfit);

            grdData.DataSource = dt;
        }
Пример #3
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            C_QuotationModel model = (C_QuotationModel)C_QuotationBO.Instance.FindByPK(id);

            frmQuotationReport frm = new frmQuotationReport();

            frm.thisQuotation = model;
            frm.Show();
        }
Пример #4
0
        public static decimal CalculateCostPB(C_QuotationDetailModel item, C_QuotationModel thisQotation, decimal price)
        {
            decimal   totalPB            = 0;
            ArrayList arr                = C_CostBO.Instance.FindByExpression(new Expression("IsUse", 1).And(new Expression("IsWithProject", 0)).And(new Expression("IsDirectCost", 0)));
            DataTable dtCostProductGroup = LibQLSX.Select("select * from vC_CostProductGroupLink where [C_ProductGroupID] = " + item.C_ProductGroupID);

            foreach (var c in arr)
            {
                C_CostModel cost = (C_CostModel)c;
                DataRow[]   drs  = dtCostProductGroup.Select("C_CostID = " + cost.ID);
                if (drs.Length == 0)
                {
                    continue;
                }
                C_CostQuotationItemLinkModel link = new C_CostQuotationItemLinkModel();

                ArrayList arrLink = C_CostQuotationItemLinkBO.Instance.FindByExpression(new Expression("C_CostID", cost.ID).And(new Expression("C_QuotationDetailID", item.ID)));
                if (arrLink != null && arrLink.Count > 0)
                {
                    link = (C_CostQuotationItemLinkModel)arrLink[0];
                }

                link.C_CostID            = cost.ID;
                link.C_QuotationDetailID = item.ID;
                link.IsDirect            = cost.IsDirectCost;
                if (link.IsDirect == 0)
                {
                    decimal valuePercent = TextUtils.ToDecimal(drs[0]["ValuePercent"]);

                    link.Price = valuePercent * item.Qty * price;
                    if (cost.IsDeliveryTime == 1)
                    {
                        link.Price *= thisQotation.DeliveryTime / 288;
                    }

                    if (cost.ID == 72 || cost.ID == 73)
                    {
                        if (cost.ID != thisQotation.DepartmentId)
                        {
                            link.Price = 0;
                        }
                    }
                    totalPB += link.Price;
                }
            }
            return(totalPB);
        }
Пример #5
0
        private void btnEditGroup_Click(object sender, EventArgs e)
        {
            int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            C_QuotationModel model = (C_QuotationModel)C_QuotationBO.Instance.FindByPK(id);

            _rownIndex = grvData.FocusedRowHandle;

            frmQuotation frm = new frmQuotation();

            frm.CurrentQuotation = model;
            frm.LoadDataChange  += main_LoadDataChange;
            frm.Show();
        }
Пример #6
0
        public static void CalculatePriceTPA(C_QuotationDetailModel item, C_QuotationModel thisQotation, decimal costTSLN, decimal costVT, decimal percentPB)
        {
            //Công thức chung
            //Gb = VTU + CPDA.NC  + CPTKE + CPDA.TKHAI + (1-1/(1+%VAT))*Gb  + %PB*Gb(1-%KH) + 1.15*%KH*Gb + 1.15*tienMat- %PB*tienMat + %LN*Gb

            if (item.ParentID == 0 && item.C_ProductGroupID == 0)
            {
                return;
            }
            decimal nhanCongTrucTiep = item.TotalNC;
            decimal costCustomer     = thisQotation.TotalCustomer;
            decimal priceTPA         = 0;
            decimal tienMat          = thisQotation.CustomerCash * item.PriceVT / costVT;

            priceTPA = (item.PriceVT + nhanCongTrucTiep + (costCustomer * item.PriceVT / costVT) + tienMat * (1.15M - percentPB))
                       / Math.Abs((1 - (1 - 1 / (1 + item.VAT / 100)) - percentPB + thisQotation.CustomerPercent / 100 * (percentPB - 1.15M) - costTSLN / 100));

            item.PriceTPA = priceTPA;
            C_QuotationDetailBO.Instance.Update(item);
        }
Пример #7
0
        private void btnApproved_Click(object sender, EventArgs e)
        {
            int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            DialogResult result = MessageBox.Show("Bạn có chắc muốn duyệt báo giá này?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }
            C_QuotationModel model = (C_QuotationModel)C_QuotationBO.Instance.FindByPK(id);

            model.IsApproved = true;
            C_QuotationBO.Instance.Update(model);
            grvData.SetFocusedRowCellValue(colIsApproved, true);
        }
Пример #8
0
 protected C_QuotationFacade(C_QuotationModel model) : base(model)
 {
 }