예제 #1
0
        /// <summary>
        /// 批量插入CVT客户基础信息
        /// </summary>
        /// <param name="cvtCustomerInfomation">CVT客户信息列表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>插入成功返回True,插入失败返回False</returns>
        public bool BatchInsertCVTCustomerInformation(DataTable cvtCustomerInfomation,
                                                      out string error)
        {
            error = null;

            string strTemp = "";

            int intFlag = 0;

            ProductListServer serverProductList = new ProductListServer();

            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                for (int i = 0; i < cvtCustomerInfomation.Rows.Count; i++)
                {
                    strTemp = cvtCustomerInfomation.Rows[i]["车架号"].ToString().Trim();

                    if (strTemp == "")
                    {
                        continue;
                    }

                    YX_CVTCustomerInformation lnqCVTCustomerInfo = new YX_CVTCustomerInformation();

                    int intGoodsID = serverProductList.GetProductGoodsID(
                        cvtCustomerInfomation.Rows[i]["CVT型号"].ToString().Trim(), 0, false);

                    if (intGoodsID == 0)
                    {
                        error = "[CVT型号]不符合标准,车架号为[" + strTemp + "]";
                        return(false);
                    }

                    if (cvtCustomerInfomation.Rows[i]["销售日期"].ToString().Trim() == "")
                    {
                        error = error + "[" + cvtCustomerInfomation.Rows[i]["车架号"].ToString().Trim() + "]";
                    }

                    var varData = from a in dataContext.YX_CVTCustomerInformation
                                  where a.VehicleShelfNumber == strTemp
                                  select a;

                    if (varData.Count() == 0)
                    {
                        lnqCVTCustomerInfo.ClientName  = cvtCustomerInfomation.Rows[i]["客户名称"].ToString().Trim();
                        lnqCVTCustomerInfo.CVTNumber   = cvtCustomerInfomation.Rows[i]["CVT编号"].ToString().Trim();
                        lnqCVTCustomerInfo.DealerName  = cvtCustomerInfomation.Rows[i]["经销商名称"].ToString().Trim();
                        lnqCVTCustomerInfo.FullAddress = cvtCustomerInfomation.Rows[i]["详细地址"].ToString().Trim();
                        lnqCVTCustomerInfo.PhoneNumber = cvtCustomerInfomation.Rows[i]["联系电话"].ToString().Trim();
                        lnqCVTCustomerInfo.ProductID   = intGoodsID;
                        lnqCVTCustomerInfo.Remark      = cvtCustomerInfomation.Rows[i]["备注"].ToString().Trim();
                        lnqCVTCustomerInfo.SellDate    = ServerTime.ConvertToDateTime(
                            cvtCustomerInfomation.Rows[i]["销售日期"].ToString().Trim());
                        lnqCVTCustomerInfo.SiteCity           = cvtCustomerInfomation.Rows[i]["车辆所在地"].ToString().Trim();
                        lnqCVTCustomerInfo.SiteProvince       = cvtCustomerInfomation.Rows[i]["省份"].ToString().Trim();
                        lnqCVTCustomerInfo.VehicleShelfNumber = strTemp;
                        lnqCVTCustomerInfo.PY         = UniversalFunction.GetPYWBCode(lnqCVTCustomerInfo.ClientName, "PY");
                        lnqCVTCustomerInfo.WB         = UniversalFunction.GetPYWBCode(lnqCVTCustomerInfo.ClientName, "WB");
                        lnqCVTCustomerInfo.CarModelID = serverProductList.GetMotorcycleType(
                            cvtCustomerInfomation.Rows[i]["车型"].ToString().Trim());
                        lnqCVTCustomerInfo.ProofNo = cvtCustomerInfomation.Rows[i]["三包凭证号"].ToString().Trim();

                        dataContext.YX_CVTCustomerInformation.InsertOnSubmit(lnqCVTCustomerInfo);
                    }
                    else
                    {
                        lnqCVTCustomerInfo = varData.Single();

                        lnqCVTCustomerInfo.SiteCity     = cvtCustomerInfomation.Rows[i]["车辆所在地"].ToString().Trim();
                        lnqCVTCustomerInfo.DealerName   = cvtCustomerInfomation.Rows[i]["经销商名称"].ToString().Trim();
                        lnqCVTCustomerInfo.SiteProvince = cvtCustomerInfomation.Rows[i]["省份"].ToString().Trim();
                        lnqCVTCustomerInfo.ClientName   = cvtCustomerInfomation.Rows[i]["客户名称"].ToString().Trim();
                        lnqCVTCustomerInfo.SellDate     =
                            ServerTime.ConvertToDateTime(cvtCustomerInfomation.Rows[i]["销售日期"].ToString().Trim());
                        lnqCVTCustomerInfo.FullAddress = cvtCustomerInfomation.Rows[i]["详细地址"].ToString().Trim();
                        lnqCVTCustomerInfo.PhoneNumber = cvtCustomerInfomation.Rows[i]["联系电话"].ToString().Trim();
                    }

                    dataContext.SubmitChanges();
                    strTemp = "";
                }

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message + ",车架号为[" + strTemp + "]" + intFlag;
                return(false);
            }
        }
        /// <summary>
        /// 批量插入装车信息
        /// </summary>
        /// <param name="loadingInfo">装车信息列表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>批量插入成功返回True,批量插入失败返回False</returns>
        public bool BatchInsertLoadingInfo(DataTable loadingInfo,
                                           out string error)
        {
            error = null;

            string strTemp = "";

            try
            {
                DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

                ProductListServer serverProductList = new ProductListServer();

                for (int i = 0; i < loadingInfo.Rows.Count; i++)
                {
                    strTemp = loadingInfo.Rows[i]["车架号"].ToString().Trim();

                    if (strTemp == "")
                    {
                        continue;
                    }

                    YX_LoadingInfo lnqLoadingInfo = new YX_LoadingInfo();

                    int intGoodsID = serverProductList.GetProductGoodsID(
                        loadingInfo.Rows[i]["CVT型号"].ToString().Trim(), 0, false);

                    if (intGoodsID == 0)
                    {
                        error = "[CVT型号]不符合标准,车架号为[" + strTemp + "]";
                        return(false);
                    }

                    int intCarModle = serverProductList.GetMotorcycleType(loadingInfo.Rows[i]["车型号"].ToString().Trim());

                    if (intCarModle == 0)
                    {
                        error = "[车型号]不符合标准,车架号为[" + strTemp + "]";
                        return(false);
                    }

                    if (loadingInfo.Rows[i]["装车日期"].ToString().Trim() == "")
                    {
                        error = error + "[" + loadingInfo.Rows[i]["车架号"].ToString().Trim() + "]";
                    }

                    lnqLoadingInfo.CarModelID = intCarModle;
                    lnqLoadingInfo.CVTNumber  = loadingInfo.Rows[i]["CVT编号"] == DBNull.Value ? ""
                        : loadingInfo.Rows[i]["CVT编号"].ToString().Trim();
                    lnqLoadingInfo.Date = ServerTime.ConvertToDateTime(
                        loadingInfo.Rows[i]["装车日期"].ToString());
                    lnqLoadingInfo.ProductID          = intGoodsID;
                    lnqLoadingInfo.Remark             = loadingInfo.Rows[i]["备注"].ToString().Trim();
                    lnqLoadingInfo.VehicleShelfNumber = loadingInfo.Rows[i]["车架号"].ToString().Trim();

                    dataContext.YX_LoadingInfo.InsertOnSubmit(lnqLoadingInfo);

                    strTemp = "";
                }

                dataContext.SubmitChanges();
                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message + ",车架号为[" + strTemp + "]";
                return(false);
            }
        }