예제 #1
0
        public static string CheckMaterialNum(Guid ProjectCode, MaterialApplyResourceCollection mrc)
        {
            string  str  = string.Empty;
            decimal num  = 0M;
            decimal num2 = 0M;

            foreach (MaterialApplyResource resource in mrc)
            {
                DataTable table = publicDbOpClass.DataTableQuary(" select ResourceType,ResourceName from EPM_V_Res_ResourceBasic where ResourceStyle=2 and ResourceCode='" + resource.ResourceCode + "' ");
                if ((table.Rows.Count > 0) && (((int)table.Rows[0]["ResourceType"]) == 1))
                {
                    DataTable table2 = publicDbOpClass.DataTableQuary(string.Concat(new object[] { " select isnull(sum(isnull(Quantity,0)),0) as Quantity from EPM_Task_Resource where ProjectCode='", ProjectCode, "' and ResourceCode='", resource.ResourceCode, "' " }));
                    if (table2.Rows.Count > 0)
                    {
                        num = Convert.ToDecimal(table2.Rows[0]["Quantity"].ToString());
                    }
                    DataTable table3 = publicDbOpClass.DataTableQuary(string.Concat(new object[] { " select isnull(sum(isnull(b.Quantity,0)),0) as Quantity from EPM_Stuff_ApplyBill a join EPM_Stuff_ApplyDetails b on a.ApplyUniqueCode=b.ApplyUniqueCode where a.ProjectCode='", ProjectCode, "' and b.ResourceCode='", resource.ResourceCode, "' " }));
                    if (table3.Rows.Count > 0)
                    {
                        num2 = Convert.ToDecimal(table3.Rows[0]["Quantity"].ToString());
                    }
                    if (num2 > num)
                    {
                        str = str + resource.ResourceCode + table.Rows[0]["ResourceName"].ToString() + ",超出预算数量!";
                    }
                }
            }
            decimal   num3   = 0M;
            decimal   num4   = 0M;
            DataTable table4 = publicDbOpClass.DataTableQuary(" select isnull(sum(isnull(Quantity,0)*isnull(UnitPrice,0)),0) as sumPrice from EPM_Task_Resource a join EPM_V_Res_ResourceBasic b on a.ResourceCode=b.ResourceCode where a.ResourceStyle=2 and b.ResourceType=2 and a.ProjectCode='" + ProjectCode + "' ");

            if (table4.Rows.Count > 0)
            {
                num3 = Convert.ToDecimal(table4.Rows[0]["sumPrice"].ToString());
            }
            DataTable table5 = publicDbOpClass.DataTableQuary(" select isnull(sum(isnull(b.Quantity,0)*isnull(b.UnitPrice,0)),0) as sumPrice from EPM_Stuff_ApplyBill a join EPM_Stuff_ApplyDetails b on a.ApplyUniqueCode=b.ApplyUniqueCode and b.ResourceStyle=2 join EPM_V_Res_ResourceBasic c on b.ResourceCode=c.ResourceCode and c.ResourceType=2 where a.ProjectCode='" + ProjectCode + "' ");

            if (table5.Rows.Count > 0)
            {
                num4 = Convert.ToDecimal(table5.Rows[0]["sumPrice"].ToString());
            }
            if (num4 > num3)
            {
                str = str + "辅材申请总额超出辅材预算总额!";
            }
            return(str);
        }
예제 #2
0
        public static bool SaveMaterialApply(MaterialApplyBill bill, MaterialApplyResourceCollection resourceList, string UserCode)
        {
            string str    = "";
            string format = " insert into EPM_Stuff_ApplyBill(ApplyUniqueCode,ApplyBillCode,ProjectCode,ApplyDate,ApplyMan,Remark,AuditInfo,AuditMan,AuditDate,AuditResult,IsAudit,IsDoOver,ApplyType) values('{0}','{1}','{2}','{3}','{4}','{5}','','',getdate(),-1,{6},0,{7}) ";
            string str3   = " update EPM_Stuff_ApplyBill set ApplyBillCode='{0}',ApplyDate='{1}',ApplyMan='{2}',Remark='{3}',IsAudit=0 where ApplyUniqueCode='{4}'";
            string str4   = " update EPM_Stuff_ApplyDetails_Temp set Quantity={0},UnitPrice={1},Supply={2},ArrivalDate='{3}',IsShow={4} where ApplyUniqueCode='{5}' and ResourceCode='{6}' and ResourceStyle={7} and UserCode ='{8}'";

            str = " begin ";
            object obj2 = str;

            str = (string.Concat(new object[] { obj2, " if not exists(select 1 from EPM_Stuff_ApplyBill where ApplyUniqueCode='", bill.ApplyUniqueCode, "')" }) + string.Format(format, new object[] { bill.ApplyUniqueCode, bill.ApplyBillCode, bill.ProjectCode, bill.ApplyDate, bill.ApplyMan, bill.Remark, bill.IsAudit ? 1 : 0, bill.ApplyType })) + " else " + string.Format(str3, new object[] { bill.ApplyBillCode, bill.ApplyDate, bill.ApplyMan, bill.Remark, bill.ApplyUniqueCode });
            for (int i = 0; i < resourceList.Count; i++)
            {
                MaterialApplyResource resource = resourceList[i];
                str = str + string.Format(str4, new object[] { resource.Quantity, resource.UnitPrice, resource.Supply, resource.ArrivalDate, resource.IsShow ? "1" : "0", bill.ApplyUniqueCode, resource.ResourceCode, resource.ResourceStyle, UserCode });
            }
            object obj3 = str;
            object obj4 = string.Concat(new object[] { obj3, " delete from EPM_Stuff_ApplyDetails where ApplyUniqueCode = '", bill.ApplyUniqueCode, "'" }) + " insert into EPM_Stuff_ApplyDetails (ApplyUniqueCode,ResourceCode,ResourceStyle,Quantity,UnitPrice,Supply,ArrivalDate,IsShow,IsDoOver,PlanID) ";

            return(publicDbOpClass.NonQuerySqlString(string.Concat(new object[] { obj4, " (select '", bill.ApplyUniqueCode, "',ResourceCode,ResourceStyle,Quantity,UnitPrice,Supply,ArrivalDate,IsShow,IsDoOver,PlanID from EPM_Stuff_ApplyDetails_Temp where ApplyUniqueCode = '", bill.ApplyUniqueCode, "' and UserCode = '", UserCode, "')" }) + " end "));
        }