コード例 #1
0
    public static List<IMAVenderCostIntervalReportData> GetVenderClientCostByInterval(WoWiModel.WoWiEntities wowidb, DateTime f, DateTime t)
    {
        List<IMAVenderCostIntervalReportData> list = new List<IMAVenderCostIntervalReportData>();
        IMAVenderCostIntervalReportData temp;
        try
        {

            var venders = (from pr in wowidb.PRs from pj in wowidb.Projects where pr.project_id == pj.Project_Id && pj.Create_Date >= f && pj.Create_Date <= t select pr.vendor_id).Distinct();
            decimal TotD = 0, TotQ = 0;

            foreach (var ven in venders)
            {
                decimal venTotD = 0, venTotQ = 0;
                try
                {
                    String vName = "";
                    var prs = from pr in wowidb.PRs where pr.vendor_id == ven select pr;
                    temp = new IMAVenderCostIntervalReportData();
                    var v = (from i in wowidb.vendors where i.id == ven select i).First();
                    temp.VenderName = String.IsNullOrEmpty(v.c_name) ? v.name : v.c_name;
                    vName = temp.VenderName;
                    foreach (var p in prs)
                    {
                        try
                        {
                            var pj = (from proj in wowidb.Projects where proj.Project_Id == p.project_id select proj).First();
                            int month = pj.Create_Date.Month;
                            var quo = (from q in wowidb.Quotation_Version where q.Quotation_Version_Id == pj.Quotation_Id select q).First();
                            temp.Model = quo.Model_No;
                            int cid = (int)quo.Client_Id;
                            try
                            {
                                var client = (from cli in wowidb.clientapplicants where cli.id == cid select cli).First();
                                temp.Client = String.IsNullOrEmpty(client.c_companyname) ? client.companyname : client.c_companyname;
                            }
                            catch
                            {
                            }

                            var pri = (from pi in wowidb.PR_item where pi.pr_id == p.pr_id select pi).First();
                            try
                            {
                                //var tDesc = (from kk in wowidb.Quotation_Target from kkk in wowidb.Targets where pri.quotation_target_id == kk.Quotation_Target_Id && kk.target_id == kkk.target_id select kkk.target_description).First();
                                var tDesc = (from kk in wowidb.Quotation_Target where pri.quotation_target_id == kk.Quotation_Target_Id select kk.target_description).First();
                                temp.Country = tDesc;

                            }
                            catch (Exception)
                            {
                            }
                            temp.TotalUSD = ((decimal)pri.amount).ToString("F2");
                            temp.TotalQTY = ((decimal)pri.quantity).ToString("F0");
                            list.Add(temp);
                            venTotD += (decimal)pri.amount;
                            venTotQ += (decimal)pri.quantity;
                        }
                        catch (Exception)
                        {

                            //throw;
                        }

                    }//Single vender ends

                    TotD += venTotD;
                    TotQ += venTotQ;
                    if (venTotD!=0)
                    {
                        temp = new IMAVenderCostIntervalReportData()
                        {
                            VenderName = " Total : "
                        };
                        temp.TotalUSD = venTotD.ToString("F2");
                        temp.TotalQTY = venTotQ.ToString("F0");
                        list.Add(temp);
                    }

                }
                catch (Exception)
                {

                    //throw;
                }
            }//Vender ends

            if (TotD != 0)
            {
                temp = new IMAVenderCostIntervalReportData()
                {
                    VenderName = "Balance Total : "
                };
                temp.TotalUSD = TotD.ToString("F2");
                temp.TotalQTY = TotQ.ToString("F0");
                list.Add(temp);
            }

        }
        catch (Exception)
        {

            //throw;
        }
        return list;
    }
コード例 #2
0
    public static List<IMAVenderCostIntervalReportData> GetIMACostByInterval(WoWiModel.WoWiEntities wowidb, DateTime f, DateTime t)
    {
        List<IMAVenderCostIntervalReportData> list = new List<IMAVenderCostIntervalReportData>();
        IMAVenderCostIntervalReportData temp;
        try
        {
            //Find all IMAs
            var imas = (from pr in wowidb.PRs from pj in wowidb.Projects where pr.project_id == pj.Project_Id && pj.Create_Date >= f && pj.Create_Date <= t select pr.create_user).Distinct();

            var venders = (from pr in wowidb.PRs from pj in wowidb.Projects where pr.project_id == pj.Project_Id && pj.Create_Date >= f && pj.Create_Date <= t select pr.vendor_id).Distinct();
            decimal TotD = 0, TotQ = 0;
            foreach (var ima in imas)
            {
                decimal imaTotD = 0, imaTotQ = 0;
                foreach (var ven in venders)
                {
                    decimal venTotD = 0, venTotQ = 0;
                    try
                    {
                        var prs = from pr in wowidb.PRs where pr.create_user == ima && pr.vendor_id == ven select pr;
                        temp = new IMAVenderCostIntervalReportData()
                        {
                            IMA = ima
                        };
                        var v = (from i in wowidb.vendors where i.id == ven select i).First();
                        temp.VenderName = String.IsNullOrEmpty(v.c_name) ? v.name : v.c_name;
                        foreach (var p in prs)
                        {
                            try
                            {
                                var pri = (from pi in wowidb.PR_item where pi.pr_id == p.pr_id select pi).First();

                                venTotD += (decimal)pri.amount;
                                venTotQ += (decimal)pri.quantity;

                            }
                            catch (Exception)
                            {

                                //throw;
                            }

                        }//Single vender ends

                        imaTotD += venTotD;
                        imaTotQ += venTotQ;
                        temp.TotalUSD = venTotD.ToString("F2");
                        temp.TotalQTY = venTotQ.ToString("F0");
                        list.Add(temp);
                    }
                    catch (Exception)
                    {

                        //throw;
                    }
                }//Vender ends
                if (imaTotD != 0)
                {
                    temp = new IMAVenderCostIntervalReportData()
                    {
                        IMA = ima + " Total : "
                    };

                    TotD += imaTotD;
                    TotQ += imaTotQ;
                    temp.TotalUSD = imaTotD.ToString("F2");
                    temp.TotalQTY = imaTotQ.ToString("F0");
                    list.Add(temp);
                }
            }//ima ends
            if (TotD != 0)
            {
                temp = new IMAVenderCostIntervalReportData()
                {
                    IMA = "Balance Total : "
                };

                temp.TotalUSD = TotD.ToString("F2");
                temp.TotalQTY = TotQ.ToString("F0");
                list.Add(temp);
            }

        }
        catch (Exception)
        {

            //throw;
        }
        return list;
    }