Пример #1
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);
        }
 protected C_CostQuotationItemLinkNewFacade(C_CostQuotationItemLinkNewModel model) : base(model)
 {
 }
Пример #3
0
        void calculateCost(C_QuotationDetail_KDModel item)
        {
            int costID    = (Quotation.DepartmentId == "D018" ? 73 : 72);//Phòng KD1->lấy ra chi phí nhân công KD2 không thì lấy chi phí nhân công KD1
            int costID_KD = (Quotation.DepartmentId == "D018" ? 72 : 73);

            if (item.C_ProductGroupID == 0)
            {
                C_CostQuotationItemLinkNewBO.Instance.DeleteByAttribute("C_QuotationDetail_KDID", item.ID);
                item.TotalNC    = 0;
                item.TotalPB    = 0;
                item.TotalNC_KD = 0;
                C_QuotationDetail_KDBO.Instance.Update(item);
            }
            else
            {
                decimal totalNC    = 0;
                decimal totalNC_KD = 0;
                decimal totalPB    = 0;

                string sql = "select *, ValuePercentKD = (select top 1 " + (Quotation.DepartmentId == "D018" ? "ValuePercentKD1" : "ValuePercentKD2")
                             + " from vC_CostProductGroupLinkNew where C_CostID = a.ID and [C_ProductGroupID] = "
                             + item.C_ProductGroupID + " and [C_VersionID] = " + Quotation.C_VersionID
                             + ") from vC_CostNew a where IsDeleted = 0 and GroupCode in ('N01','N05','N08','N09','N11')";
                DataTable dtCost = LibQLSX.Select(sql);

                foreach (DataRow row in dtCost.Rows)
                {
                    string code      = TextUtils.ToString(row["Code"]);
                    string groupCode = TextUtils.ToString(row["GroupCode"]);

                    C_CostQuotationItemLinkNewModel link = new C_CostQuotationItemLinkNewModel();
                    ArrayList arrLink = C_CostQuotationItemLinkNewBO.Instance.FindByExpression(new Expression("C_CostID", TextUtils.ToInt(row["ID"])).And(new Expression("C_QuotationDetail_KDID", item.ID)));
                    if (arrLink != null && arrLink.Count > 0)
                    {
                        link = (C_CostQuotationItemLinkNewModel)arrLink[0];
                    }

                    link.C_CostID = TextUtils.ToInt(row["ID"]);
                    link.C_QuotationDetail_KDID = item.ID;
                    if (link.C_CostID == costID)
                    {
                        link.Price = 0;
                    }
                    else
                    {
                        link.Price = TextUtils.ToDecimal(row["ValuePercentKD"]) / 100 * (link.C_CostID == 10 ? item.PriceTPA : item.PriceCP);//lãi vay tính theo giá theo tpa
                    }

                    if (groupCode == "N05")//nhan cong kinh doanh
                    {
                        totalNC_KD += link.Price;
                    }
                    else if (groupCode == "N01")// nhan cong gian tiep khac
                    {
                        totalNC += link.Price;
                    }
                    else
                    {
                        totalPB += link.Price;
                    }

                    if (link.ID == 0)
                    {
                        C_CostQuotationItemLinkNewBO.Instance.Insert(link);
                    }
                    else
                    {
                        C_CostQuotationItemLinkNewBO.Instance.Update(link);
                    }
                }
                item.TotalNC_KD = totalNC_KD;
                item.TotalNC    = totalNC;
                item.TotalPB    = totalPB;
                C_QuotationDetail_KDBO.Instance.Update(item);
            }
        }
Пример #4
0
        void calculateCost(C_QuotationDetail_SXModel item)
        {
            int costID = (Quotation.DepartmentId == "D018" ? 73 : 72);//Phòng KD1->lấy ra chi phí nhân công KD2 không thì lấy chi phí nhân công KD1

            if (item.C_ProductGroupID == 0)
            {
                C_CostQuotationItemLinkNewBO.Instance.DeleteByAttribute("C_QuotationDetail_SXID", item.ID);
                item.TotalNC = 0;
                item.TotalPB = 0;
                C_QuotationDetail_SXBO.Instance.Update(item);
            }
            else
            {
                ArrayList arr = C_CostBO.Instance.FindByExpression(new Expression("IsUse", 1).And(new Expression("IsWithProject", 0)));
                DataTable dtCostProductGroup = LibQLSX.Select("select * from vC_CostProductGroupLinkNew where [C_ProductGroupID] = " + item.C_ProductGroupID);
                decimal   totalNC            = 0;
                decimal   totalPB            = 0;
                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_CostQuotationItemLinkNewModel link = new C_CostQuotationItemLinkNewModel();

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

                    link.C_CostID = cost.ID;
                    link.C_QuotationDetail_SXID = item.ID;
                    link.IsDirect = cost.IsDirectCost;
                    if (link.IsDirect == 1)
                    {
                        #region Chi phí nhân công
                        if (link.ID == 0)
                        {
                            if (cost.Price == 0)
                            {
                                link.Price = 0;
                            }
                            else
                            {
                                link.PersonNumber = TextUtils.ToDecimal(drs[0]["PersonNumber"]);
                                int isFix = TextUtils.ToInt(drs[0]["IsFix"]);
                                if (isFix == 1)
                                {
                                    link.NumberDay = TextUtils.ToDecimal(drs[0]["NumberDay"]);
                                }
                                else
                                {
                                    link.NumberDay = TextUtils.ToDecimal(drs[0]["VtuPercent"]) * item.PriceVT / cost.Price;
                                }
                                link.TotalR = link.NumberDay * link.PersonNumber;
                                if (cost.ID == 61)//phòng thiết kế
                                {
                                    link.TotalR = link.NumberDay * link.PersonNumber * (1 + 0.3M * (item.Qty - 1)) / item.Qty;
                                    //link.Price = (link.NumberDay * link.PersonNumber) * (1 + 0.3M * (item.Qty - 1)) / item.Qty * cost.Price;
                                }
                                link.Price = link.TotalR * cost.Price;
                            }
                        }

                        totalNC += link.Price;
                        #endregion
                    }
                    else
                    {
                        #region Chi phí phân bổ
                        if (item.PriceHD > 0)
                        {
                            decimal valuePercent = TextUtils.ToDecimal(drs[0]["ValuePercentSX"]);

                            link.Price = valuePercent / 100 * item.PriceTPA;

                            if (link.C_CostID == costID)
                            {
                                link.Price = 0;
                            }
                            else
                            {
                                //link.Price = TextUtils.ToDecimal(row["ValuePercentSX"]) / 100 * item.PriceTPA;
                            }
                        }
                        #endregion
                    }

                    if (link.ID == 0)
                    {
                        C_CostQuotationItemLinkNewBO.Instance.Insert(link);
                    }
                    else
                    {
                        C_CostQuotationItemLinkNewBO.Instance.Update(link);
                    }

                    item.TotalNC = totalNC;
                    item.TotalPB = totalPB;
                    C_QuotationDetail_SXBO.Instance.Update(item);
                }
            }
        }
Пример #5
0
        void calculateCost_PB(C_QuotationDetail_SXModel item)
        {
            int costID = (Quotation.DepartmentId == "D018" ? 73 : 72);//Phòng KD1->lấy ra chi phí nhân công KD2 không thì lấy chi phí nhân công KD1

            if (item.C_ProductGroupID == 0)
            {
                C_CostQuotationItemLinkNewBO.Instance.DeleteByAttribute("C_QuotationDetail_SXID", item.ID);
                item.TotalNC = 0;
                item.TotalPB = 0;
                C_QuotationDetail_KDBO.Instance.Update(item);
            }
            else
            {
                //ArrayList arr = C_CostBO.Instance.FindByExpression(new Expression("IsUse", 1));
                string sql = "";
                if (Quotation.StatusNC == 1)
                {
                    sql = "select *, ValuePercentSX = (select top 1 ValuePercentSX from vC_CostProductGroupLinkNew where C_CostID = a.ID and [C_ProductGroupID] = "
                          + item.C_ProductGroupID + " and [C_VersionID] = " + Quotation.C_VersionID + ") from vC_CostNew a where IsUse = 1 and IsDeleted = 0 and GroupCode in ('N01','N08','N09','N11','N02','N03','N04','N07.02','N07.03')";
                }
                else
                {
                    sql = "select *, ValuePercentSX = (select top 1 ValuePercentSX from vC_CostProductGroupLinkNew where C_CostID = a.ID and [C_ProductGroupID] = "
                          + item.C_ProductGroupID + " and [C_VersionID] = " + Quotation.C_VersionID + ") from vC_CostNew a where IsUse = 1 and IsDeleted = 0 and GroupCode in ('N01','N08','N09','N11')";
                }

                DataTable dtCost = LibQLSX.Select(sql);

                foreach (DataRow row in dtCost.Rows)
                {
                    string code = TextUtils.ToString(row["Code"]);
                    C_CostQuotationItemLinkNewModel link = new C_CostQuotationItemLinkNewModel();
                    ArrayList arrLink = C_CostQuotationItemLinkNewBO.Instance.FindByExpression(new Expression("C_CostID", TextUtils.ToInt(row["ID"]))
                                                                                               .And(new Expression("C_QuotationDetail_SXID", item.ID)));
                    if (arrLink != null && arrLink.Count > 0)
                    {
                        link = (C_CostQuotationItemLinkNewModel)arrLink[0];
                    }

                    link.C_CostID = TextUtils.ToInt(row["ID"]);
                    link.C_QuotationDetail_SXID = item.ID;
                    //if (link.C_CostID == costID)
                    //{
                    //    link.Price = 0;
                    //}
                    //else
                    //{
                    link.Price = TextUtils.ToDecimal(row["ValuePercentSX"]) / 100 * item.PriceTPA;
                    //}

                    if (link.ID == 0)
                    {
                        C_CostQuotationItemLinkNewBO.Instance.Insert(link);
                    }
                    else
                    {
                        C_CostQuotationItemLinkNewBO.Instance.Update(link);
                    }
                }
                C_QuotationDetail_KDBO.Instance.Update(item);
            }
        }
Пример #6
0
        void saveCN(ProcessTransaction pt, int count, DataRow row)
        {
            int     stt = TextUtils.ToInt(row["F1"]);
            decimal qty = TextUtils.ToDecimal(row["F7"]);

            C_QuotationDetail_SXModel item = new C_QuotationDetail_SXModel();

            item.C_QuotationID = Quotation.ID;
            item.ParentID      = 0;
            item.Qty           = item.QtyT = qty;
            item.PriceVT       = TextUtils.ToDecimal(row["F47"]);
            item.PriceVTTN     = TextUtils.ToDecimal(row["F48"]);
            item.PriceVTPS     = TextUtils.ToDecimal(row["F49"]);
            item.Manufacture   = TextUtils.ToString(row["F4"]);
            item.ModuleCode    = TextUtils.ToString(row["F3"]);
            item.ModuleName    = TextUtils.ToString(row["F2"]);
            item.Origin        = TextUtils.ToString(row["F5"]);

            item.C_ProductGroupID = TextUtils.ToInt(LibQLSX.ExcuteScalar("select ID from C_ProductGroup where Code = '" + TextUtils.ToString(row["F6"]) + "'"));

            item.ID = (int)pt.Insert(item);
            count++;
            row["ID"] = item.ID;

            DataRow[] drs = _dtData.Select("F1 like '" + stt + ".%'");
            foreach (DataRow rowC in drs)
            {
                decimal qtyC      = TextUtils.ToDecimal(rowC["F7"]);
                string  groupCode = TextUtils.ToString(rowC["F6"]);

                int groupID = TextUtils.ToInt(LibQLSX.ExcuteScalar("select ID from C_ProductGroup where Code = '" + groupCode + "'"));

                C_QuotationDetail_SXModel itemC = new C_QuotationDetail_SXModel();
                itemC.C_QuotationID    = Quotation.ID;
                itemC.ParentID         = item.ID;
                itemC.C_ProductGroupID = groupID;

                itemC.Qty       = qtyC;
                itemC.QtyT      = qtyC / item.Qty;
                itemC.PriceVT   = TextUtils.ToDecimal(rowC["F47"]);
                itemC.PriceVTTN = TextUtils.ToDecimal(row["F48"]);
                itemC.PriceVTPS = TextUtils.ToDecimal(row["F49"]);

                itemC.ModuleName  = TextUtils.ToString(rowC["F2"]);
                itemC.ModuleCode  = TextUtils.ToString(rowC["F3"]);
                itemC.Manufacture = TextUtils.ToString(rowC["F4"]);
                itemC.Origin      = TextUtils.ToString(rowC["F5"]);

                itemC.ID   = (int)pt.Insert(itemC);
                rowC["ID"] = itemC.ID;
                count++;

                #region Chi phí nhân công

                //Phòng thiết kê
                C_CostQuotationItemLinkNewModel linkP24 = new C_CostQuotationItemLinkNewModel();
                linkP24.C_CostID = Quotation.CreatedDepartmentID == 18 ? 101 : 61;
                linkP24.C_QuotationDetail_SXID = itemC.ID;
                linkP24.NumberDay    = TextUtils.ToDecimal(rowC["F10"]);
                linkP24.PersonNumber = TextUtils.ToDecimal(rowC["F9"]);
                linkP24.CostNCType   = TextUtils.ToString(rowC["F12"]);
                linkP24.TotalR       = linkP24.NumberDay * linkP24.PersonNumber;
                linkP24.Price        = linkP24.TotalR * TextUtils.ToDecimal(LibQLSX.ExcuteScalar("select Price from C_CostNCType where C_CostID = "
                                                                                                 + linkP24.C_CostID + " and CostNCType = '" + linkP24.CostNCType + "'"));//pricePerDay;
                linkP24.IsDirect = 1;
                pt.Insert(linkP24);

                //Phòng SXLR
                C_CostQuotationItemLinkNewModel linkP07 = new C_CostQuotationItemLinkNewModel();
                linkP07.C_CostID = 64;
                linkP07.C_QuotationDetail_SXID = itemC.ID;
                linkP07.NumberDay    = TextUtils.ToDecimal(rowC["F16"]);
                linkP07.PersonNumber = TextUtils.ToDecimal(rowC["F15"]);
                linkP07.CostNCType   = TextUtils.ToString(rowC["F17"]);
                linkP07.TotalR       = linkP07.NumberDay * linkP07.PersonNumber;
                linkP07.Price        = linkP07.TotalR * TextUtils.ToDecimal(LibQLSX.ExcuteScalar("select Price from C_CostNCType where C_CostID = "
                                                                                                 + linkP07.C_CostID + " and CostNCType = '" + linkP07.CostNCType + "'")); //pricePerDay;
                linkP07.IsDirect = 1;
                pt.Insert(linkP07);

                //Phòng Service
                C_CostQuotationItemLinkNewModel linkP12 = new C_CostQuotationItemLinkNewModel();
                linkP12.C_CostID = 63;
                linkP12.C_QuotationDetail_SXID = itemC.ID;
                linkP12.NumberDay    = TextUtils.ToDecimal(rowC["F21"]);
                linkP12.PersonNumber = TextUtils.ToDecimal(rowC["F20"]);
                linkP12.CostNCType   = TextUtils.ToString(rowC["F22"]);
                linkP12.TotalR       = linkP12.NumberDay * linkP12.PersonNumber;
                linkP12.Price        = linkP12.TotalR * TextUtils.ToDecimal(LibQLSX.ExcuteScalar("select Price from C_CostNCType where C_CostID = "
                                                                                                 + linkP12.C_CostID + " and CostNCType = '" + linkP12.CostNCType + "'"));//pricePerDay;
                linkP12.IsDirect = 1;
                pt.Insert(linkP12);

                //Phòng PLD
                C_CostQuotationItemLinkNewModel linkPLD = new C_CostQuotationItemLinkNewModel();
                linkPLD.C_CostID = 103;
                linkPLD.C_QuotationDetail_SXID = itemC.ID;
                linkPLD.NumberDay    = TextUtils.ToDecimal(rowC["F30"]);
                linkPLD.PersonNumber = TextUtils.ToDecimal(rowC["F29"]);
                linkPLD.CostNCType   = TextUtils.ToString(rowC["F31"]);
                linkPLD.TotalR       = linkPLD.NumberDay * linkPLD.PersonNumber;
                linkPLD.Price        = linkPLD.TotalR * TextUtils.ToDecimal(LibQLSX.ExcuteScalar("select Price from C_CostNCType where C_CostID = "
                                                                                                 + linkPLD.C_CostID + " and CostNCType = '" + linkPLD.CostNCType + "'"));//pricePerDay;
                linkPLD.IsDirect = 1;
                pt.Insert(linkPLD);

                //Phòng PCG
                C_CostQuotationItemLinkNewModel linkPCG = new C_CostQuotationItemLinkNewModel();
                linkPCG.C_CostID = 104;
                linkPCG.C_QuotationDetail_SXID = itemC.ID;
                linkPCG.NumberDay    = TextUtils.ToDecimal(rowC["F35"]);
                linkPCG.PersonNumber = TextUtils.ToDecimal(rowC["F34"]);
                linkPCG.CostNCType   = TextUtils.ToString(rowC["F36"]);
                linkPCG.TotalR       = linkPCG.NumberDay * linkPCG.PersonNumber;
                linkPCG.Price        = linkPCG.TotalR * TextUtils.ToDecimal(LibQLSX.ExcuteScalar("select Price from C_CostNCType where C_CostID = "
                                                                                                 + linkPCG.C_CostID + " and CostNCType = '" + linkPCG.CostNCType + "'"));//pricePerDay;
                linkPCG.IsDirect = 1;
                pt.Insert(linkPCG);
                #endregion
            }
        }