Beispiel #1
0
        public override void etAfterCfl(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent)
        {
            base.etAfterCfl(ref pVal, ref BubbleEvent);
            SAPbouiCOM.IChooseFromListEvent oCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pVal;
            SAPbouiCOM.DataTable            dtSel      = oCFLEvento.SelectedObjects;
            if (pVal.ItemUID == txCode.Item.UniqueID)
            {
                if (dtSel != null && dtSel.Rows.Count > 0)
                {
                    string strCode = dtSel.GetValue("ItemCode", 0).ToString();
                    string strName = dtSel.GetValue("ItemName", 0).ToString();
                    string Remarks = dtSel.GetValue("U_B1_BOQREM", 0).ToString();
                    string Qty     = dtSel.GetValue("U_B1_BOQQty", 0).ToString();
                    double APC     = getAPCCost(strCode);
                    BOQH.SetValue("ItemCode", 0, strCode);
                    BOQH.SetValue("ItemName", 0, strName);
                    BOQH.SetValue("Remarks", 0, Remarks);
                    BOQH.SetValue("Qty", 0, Qty);
                    BOQH.SetValue("APC", 0, APC);

                    fillDetails(strCode);
                    getIndirectCost(strCode);

                    addEmptyRow(mtDC, BOQD, "CostCode");
                }
            }

            if (pVal.ItemUID == mtDC.Item.UniqueID && pVal.ColUID == "cCode")
            {
                if (dtSel != null && dtSel.Rows.Count > 0)
                {
                    SAPbouiCOM.ComboBox cbColType = (SAPbouiCOM.ComboBox)mtDC.Columns.Item("cType").Cells.Item(pVal.Row).Specific;
                    if (cbColType.Selected.Value == "I")
                    {
                        string strCode = dtSel.GetValue("ItemCode", 0).ToString();
                        string strName = dtSel.GetValue("ItemName", 0).ToString();
                        BOQD.SetValue("Code", pVal.Row - 1, strCode);
                        BOQD.SetValue("Name", pVal.Row - 1, strName);
                    }
                    if (cbColType.Selected.Value == "S")
                    {
                        string strCode = dtSel.GetValue("AcctCode", 0).ToString();
                        string strName = dtSel.GetValue("AcctName", 0).ToString();
                        BOQD.SetValue("Code", pVal.Row - 1, strCode);
                        BOQD.SetValue("Name", pVal.Row - 1, strName);
                    }
                    mtDC.LoadFromDataSource();
                }
            }
        }
Beispiel #2
0
        private void fillDetails(string itemCode)
        {
            BOQD.Rows.Clear();
            double dbgtTotal = 0.00;
            double dactTotal = 0.00;

            //   addEmptyRow(mtDC, BOQD, "CostCode");
            // string strQD = "   Select * from [@B1_DBOQD] where  u_ItemCode='" + itemCode + "'";
            Hashtable hp = new Hashtable();

            hp.Add("~p1", itemCode);
            string strQD = Program.objHrmsUI.getQryString("DBOQ_FD_005", hp);

            System.Data.DataTable dtQD = Program.objHrmsUI.getDataTable(strQD, "getting details");
            if (dtQD.Rows.Count > 0)
            {
                BOQD.Rows.Add(dtQD.Rows.Count);
                int i = 0;
                foreach (System.Data.DataRow dr in dtQD.Rows)
                {
                    BOQD.SetValue("Id", i, (i + 1).ToString());
                    BOQD.SetValue("CostCode", i, dr["Code"].ToString());
                    BOQD.SetValue("STD", i, Convert.ToDateTime(dr["U_WBSStD"]).ToString("yyyyMMdd"));
                    BOQD.SetValue("ETD", i, Convert.ToDateTime(dr["U_WBSED"]).ToString("yyyyMMdd"));
                    BOQD.SetValue("WBL", i, Convert.ToString(dr["U_WBSLevel"]).ToString());
                    BOQD.SetValue("WBD", i, Convert.ToString(dr["U_WBSDscr"]).ToString());
                    BOQD.SetValue("Type", i, Convert.ToString(dr["U_Type"]).ToString());
                    BOQD.SetValue("Code", i, Convert.ToString(dr["U_rCode"]).ToString());
                    BOQD.SetValue("Name", i, Convert.ToString(dr["U_rName"]).ToString());
                    BOQD.SetValue("Remarks", i, Convert.ToString(dr["U_Remarks"]).ToString());
                    BOQD.SetValue("Qty", i, Convert.ToString(dr["U_Qty"]).ToString());
                    BOQD.SetValue("UP", i, Convert.ToString(dr["U_Price"]).ToString());
                    BOQD.SetValue("BGTC", i, Convert.ToString(dr["U_BgtCost"]).ToString());
                    double ActValue = getActCost(dr["Code"].ToString());
                    BOQD.SetValue("ACTC", i, ActValue);

                    dbgtTotal += Convert.ToDouble(dr["U_BgtCost"]);
                    dactTotal += ActValue;

                    i++;
                }
            }
            mtDC.LoadFromDataSource();
            BOQH.SetValue("ICB", 0, dbgtTotal);
            BOQH.SetValue("ICA", 0, dactTotal);

            oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE;
        }
Beispiel #3
0
        private void getIndirectCost(string FACode)
        {
            BOQID.Rows.Clear();
            System.Data.DataTable dtIndirectCostCode = new System.Data.DataTable();
            dtIndirectCostCode.Columns.Add("CostCode");
            dtIndirectCostCode.Columns.Add("AR");
            dtIndirectCostCode.Columns.Add("Budget");

            System.Data.DataTable AMS = new System.Data.DataTable();
            AMS.Columns.Add("AM");
            AMS.Columns.Add("Father");


            Hashtable hp = new Hashtable();

            hp.Add("~p1", FACode);
            System.Data.DataTable dtFA = Program.objHrmsUI.getDataTableQryCode("DBOQ_IC_001", hp, "Fill Root");

            if (dtFA.Rows.Count > 0)
            {
                foreach (System.Data.DataRow drFA in dtFA.Rows)
                {
                    string AM     = drFA["Code"].ToString();
                    string Father = drFA["U_Father"].ToString();
                    while (AM != "0")
                    {
                        AMS.Rows.Add(AM, Father);
                        hp.Clear();
                        hp.Add("~p1", Father);
                        string strFather = Program.objHrmsUI.getQryString("DBOQ_IC_002", hp);

                        System.Data.DataTable dtFather = Program.objHrmsUI.getDataTable(strFather, "Father");
                        if (dtFather.Rows.Count > 0)
                        {
                            AM     = dtFather.Rows[0]["Code"].ToString();
                            Father = dtFather.Rows[0]["U_Father"].ToString();
                        }
                        else
                        {
                            Father = "0";
                            AM     = "Root";
                        }
                    }
                }
            }
            double indirectCostBudget = 0.00;
            double indirectCostActual = 0.00;

            foreach (System.Data.DataRow drAM in AMS.Rows)
            {
                hp.Clear();
                hp.Add("~p1", drAM["AM"].ToString());
                string strSqlAR = Program.objHrmsUI.getQryString("DBOQ_IC_003", hp);
                System.Data.DataTable dtRule = Program.objHrmsUI.getDataTable(strSqlAR, "Allocation Rule");
                if (dtRule.Rows.Count > 0)
                {
                    foreach (System.Data.DataRow drAR in dtRule.Rows)
                    {
                        hp.Clear();
                        hp.Add("~p1", drAR["AR"].ToString());
                        string strCosts = Program.objHrmsUI.getQryString("DBOQ_IC_004", hp);
                        System.Data.DataTable dtCostCodes = Program.objHrmsUI.getDataTable(strCosts, "Indirect Cost Codes");
                        foreach (System.Data.DataRow drCostCode in dtCostCodes.Rows)
                        {
                            BOQID.Rows.Add(1);
                            BOQID.SetValue("CostCode", BOQID.Rows.Count - 1, drCostCode["code"].ToString());
                            BOQID.SetValue("STD", BOQID.Rows.Count - 1, Convert.ToDateTime(drCostCode["U_WBSStd"]));
                            BOQID.SetValue("ETD", BOQID.Rows.Count - 1, Convert.ToDateTime(drCostCode["U_WBSED"]));
                            BOQID.SetValue("WBL", BOQID.Rows.Count - 1, drCostCode["U_WBSLevel"].ToString());
                            BOQID.SetValue("WBD", BOQID.Rows.Count - 1, drCostCode["U_WBSDscr"].ToString());
                            double indirectCost    = getIndirectACt(drCostCode["code"].ToString(), FACode);
                            double indirectBgtCost = Convert.ToDouble(drCostCode["U_BgtCost"]) * (Convert.ToDouble(drAR["AP"]) / 100.00);

                            BOQID.SetValue("BGTC", BOQID.Rows.Count - 1, indirectBgtCost);
                            BOQID.SetValue("ACTC", BOQID.Rows.Count - 1, indirectCost);
                            BOQID.SetValue("Remarks", BOQID.Rows.Count - 1, drCostCode["U_Remarks"].ToString());

                            indirectCostActual += indirectCost;
                            indirectCostBudget += indirectBgtCost;
                        }
                    }
                }
            }
            BOQH.SetValue("ICB", 0, indirectCostBudget);
            BOQH.SetValue("ICA", 0, indirectCostActual);

            BOQH.SetValue("TCB", 0, indirectCostBudget + Convert.ToDouble(BOQH.GetValue("DCB", 0)));
            BOQH.SetValue("TCA", 0, indirectCostActual + Convert.ToDouble(BOQH.GetValue("DCA", 0)));

            mtIC.LoadFromDataSource();
        }