Esempio n. 1
0
 public static DataTable GetPurchaseIncomeInfo(string CodeNo, string Title,
                                               string CustName, string StartDate, string EndDate, int pageIndex, int pageSize, string OrderBy, ref int totalCount)
 {
     try
     {
         string CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
         return(BillingDBHelper.GetPurchaseIncomeInfo(CompanyCD, CodeNo, Title, CustName, StartDate, EndDate, pageIndex, pageSize, OrderBy, ref totalCount));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 获取业务单对应的源单的详细信息
        /// </summary>
        /// <param name="BillingID">业务单主键ID</param>
        /// <returns></returns>
        public DataTable GetSourceDt(int BillingID, string CompanyCD, string PayOrIncomeType)
        {
            try
            {
                DataTable returnDT = new DataTable();

                if (IsExist(BillingID, CompanyCD, PayOrIncomeType))
                {
                    returnDT = GetBlendingSourse(CompanyCD, BillingID.ToString(), PayOrIncomeType);
                }
                else
                {
                    string         sql   = @"select a.SourceID,a.SourceDt,a.BillingType,a.InvoiceType,isnull(a.CurrencyType,0) as CurrencyType,isnull(a.CurrencyRate,1) as Rate ,isnull(b.CurrencyName,'') as CurrencyName from officedba.Billing a left outer join officedba.CurrencyTypeSetting b on a.CurrencyType=b.ID where a.ID=@ID and b.CompanyCD=@CompanyCD and a.CompanyCD=@CompanyCDD ";
                    SqlParameter[] parms =
                    {
                        new SqlParameter("@ID",         BillingID),
                        new SqlParameter("@CompanyCD",  CompanyCD),
                        new SqlParameter("@CompanyCDD", CompanyCD)
                    };
                    DataTable dt    = SqlHelper.ExecuteSql(sql, parms);
                    DataTable RevDt = new DataTable();

                    string ids          = string.Empty;
                    string Fromtable    = string.Empty;
                    string BillingType  = string.Empty;
                    string InvoiceType  = string.Empty;
                    string CurrencyName = string.Empty;
                    string Rate         = string.Empty;
                    string CurrencyType = string.Empty;
                    returnDT.Columns.Add("SourceDt");     //源单表
                    returnDT.Columns.Add("SourceID");     //源单ID
                    returnDT.Columns.Add("BillCD");       //源单编码
                    returnDT.Columns.Add("BillingType");  //源单类别
                    returnDT.Columns.Add("InvoiceType");  //发票类别
                    returnDT.Columns.Add("TotalPrice");   //源单总金额
                    returnDT.Columns.Add("ContactUnits"); //往来客户
                    returnDT.Columns.Add("CurrencyType");
                    returnDT.Columns.Add("Rate");
                    returnDT.Columns.Add("CurrencyName");

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        ids          = dt.Rows[0]["SourceID"].ToString();
                        Fromtable    = dt.Rows[0]["SourceDt"].ToString().Trim();
                        BillingType  = dt.Rows[0]["BillingType"].ToString();
                        InvoiceType  = dt.Rows[0]["InvoiceType"].ToString();
                        CurrencyName = dt.Rows[0]["CurrencyName"].ToString();
                        Rate         = dt.Rows[0]["Rate"].ToString();
                        CurrencyType = dt.Rows[0]["CurrencyType"].ToString();

                        switch (Fromtable)
                        {
                        case "officedba.SellOrder":
                            RevDt = SellOrderDBHelper.SearchOrderByCondition(ids, CompanyCD);
                            for (int i = 0; i < RevDt.Rows.Count; i++)
                            {
                                DataRow row = returnDT.NewRow();
                                row["SourceDt"]     = Fromtable;
                                row["SourceID"]     = RevDt.Rows[i]["ID"].ToString();
                                row["BillCD"]       = RevDt.Rows[i]["OrderNo"].ToString();
                                row["BillingType"]  = BillingType;
                                row["InvoiceType"]  = InvoiceType;
                                row["TotalPrice"]   = RevDt.Rows[i]["RealTotal"].ToString();
                                row["ContactUnits"] = RevDt.Rows[i]["CustName"].ToString();
                                row["CurrencyName"] = CurrencyName;
                                row["CurrencyType"] = CurrencyType;
                                row["Rate"]         = Rate;
                                returnDT.Rows.Add(row);
                            }
                            break;

                        case "officedba.PurchaseOrder":
                            RevDt = PurchaseOrderDBHelper.SearchOrderByCondition(ids, CompanyCD);
                            for (int i = 0; i < RevDt.Rows.Count; i++)
                            {
                                DataRow row = returnDT.NewRow();
                                row["SourceDt"]     = Fromtable;
                                row["SourceID"]     = RevDt.Rows[i]["ID"].ToString();
                                row["BillCD"]       = RevDt.Rows[i]["OrderNo"].ToString();
                                row["BillingType"]  = BillingType;
                                row["InvoiceType"]  = InvoiceType;
                                row["TotalPrice"]   = RevDt.Rows[i]["RealTotal"].ToString();
                                row["ContactUnits"] = RevDt.Rows[i]["CustName"].ToString();
                                row["CurrencyName"] = CurrencyName;
                                row["CurrencyType"] = CurrencyType;
                                row["Rate"]         = Rate;
                                returnDT.Rows.Add(row);
                            }
                            break;

                        case "officedba.SellBack":
                            RevDt = BillingDBHelper.SellBackInfo(ids, CompanyCD);
                            for (int i = 0; i < RevDt.Rows.Count; i++)
                            {
                                DataRow row = returnDT.NewRow();
                                row["SourceDt"]     = Fromtable;
                                row["SourceID"]     = RevDt.Rows[i]["ID"].ToString();
                                row["BillCD"]       = RevDt.Rows[i]["BackNo"].ToString();
                                row["BillingType"]  = BillingType;
                                row["InvoiceType"]  = InvoiceType;
                                row["TotalPrice"]   = RevDt.Rows[i]["RealTotal"].ToString();
                                row["ContactUnits"] = RevDt.Rows[i]["CustName"].ToString();
                                row["CurrencyName"] = CurrencyName;
                                row["CurrencyType"] = CurrencyType;
                                row["Rate"]         = Rate;
                                returnDT.Rows.Add(row);
                            }
                            break;

                        case "officedba.SellChannelSttl":
                            RevDt = BillingDBHelper.GetSellChannelSttlInfo(ids, CompanyCD);
                            for (int i = 0; i < RevDt.Rows.Count; i++)
                            {
                                DataRow row = returnDT.NewRow();
                                row["SourceDt"]     = Fromtable;
                                row["SourceID"]     = RevDt.Rows[i]["ID"].ToString();
                                row["BillCD"]       = RevDt.Rows[i]["SttlNo"].ToString();
                                row["BillingType"]  = BillingType;
                                row["InvoiceType"]  = InvoiceType;
                                row["TotalPrice"]   = RevDt.Rows[i]["SttlTotal"].ToString();
                                row["ContactUnits"] = RevDt.Rows[i]["CustName"].ToString();
                                row["CurrencyName"] = CurrencyName;
                                row["CurrencyType"] = CurrencyType;
                                row["Rate"]         = Rate;
                                returnDT.Rows.Add(row);
                            }
                            break;

                        case "officedba.PurchaseReject":
                            RevDt = BillingDBHelper.GetPurchaseRejectInfo(ids, CompanyCD);
                            for (int i = 0; i < RevDt.Rows.Count; i++)
                            {
                                DataRow row = returnDT.NewRow();
                                row["SourceDt"]     = Fromtable;
                                row["SourceID"]     = RevDt.Rows[i]["ID"].ToString();
                                row["BillCD"]       = RevDt.Rows[i]["OrderNO"].ToString();
                                row["BillingType"]  = BillingType;
                                row["InvoiceType"]  = InvoiceType;
                                row["TotalPrice"]   = RevDt.Rows[i]["RealTotal"].ToString();
                                row["ContactUnits"] = RevDt.Rows[i]["CustName"].ToString();
                                row["CurrencyName"] = CurrencyName;
                                row["CurrencyType"] = CurrencyType;
                                row["Rate"]         = Rate;
                                returnDT.Rows.Add(row);
                            }
                            break;

                        case "officedba.PurchaseArrive":
                            RevDt = BillingDBHelper.GetPurchaseIncomeInfo(ids, CompanyCD);
                            for (int i = 0; i < RevDt.Rows.Count; i++)
                            {
                                DataRow row = returnDT.NewRow();
                                row["SourceDt"]     = Fromtable;
                                row["SourceID"]     = RevDt.Rows[i]["ID"].ToString();
                                row["BillCD"]       = RevDt.Rows[i]["OrderNO"].ToString();
                                row["BillingType"]  = BillingType;
                                row["InvoiceType"]  = InvoiceType;
                                row["TotalPrice"]   = RevDt.Rows[i]["RealTotal"].ToString();
                                row["ContactUnits"] = RevDt.Rows[i]["CustName"].ToString();
                                row["CurrencyName"] = CurrencyName;
                                row["CurrencyType"] = CurrencyType;
                                row["Rate"]         = Rate;
                                returnDT.Rows.Add(row);
                            }
                            break;

                        case "officedba.SellSend":
                            RevDt = BillingDBHelper.GetSellSendInfo(ids, CompanyCD);
                            for (int i = 0; i < RevDt.Rows.Count; i++)
                            {
                                DataRow row = returnDT.NewRow();
                                row["SourceDt"]     = Fromtable;
                                row["SourceID"]     = RevDt.Rows[i]["ID"].ToString();
                                row["BillCD"]       = RevDt.Rows[i]["OrderNO"].ToString();
                                row["BillingType"]  = BillingType;
                                row["InvoiceType"]  = InvoiceType;
                                row["TotalPrice"]   = RevDt.Rows[i]["RealTotal"].ToString();
                                row["ContactUnits"] = RevDt.Rows[i]["CustName"].ToString();
                                row["CurrencyName"] = CurrencyName;
                                row["CurrencyType"] = CurrencyType;
                                row["Rate"]         = Rate;
                                returnDT.Rows.Add(row);
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
                return(returnDT);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }