Esempio n. 1
0
        protected override void Inject(IDataReader source, object target)
        {
            for (var i = 0; i < source.FieldCount; i++)
            {
                var activeTarget = target.GetProps().GetByName(source.GetName(i), true);
                if (activeTarget == null)
                {
                    continue;
                }

                var value = source.GetValue(i);
                if (value == DBNull.Value)
                {
                    continue;
                }

                if (activeTarget.PropertyType.Name == "Int32")
                {
                    activeTarget.SetValue(target, PublicMethod.GetInt(value));
                }
                else if (activeTarget.PropertyType.Name == "Boolean")
                {
                    activeTarget.SetValue(target, PublicMethod.GetBool(value));
                }
                else
                {
                    activeTarget.SetValue(target, value);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// DataTable To List
        /// </summary>
        /// <typeparam name="TType">object type</typeparam>
        /// <param name="dt">DataTable</param>
        /// <returns></returns>
        public static List <T> DataTableToObjectList <T>(DataTable dt) where T : new()
        {
            DataColumnCollection columns = dt.Columns;
            int      columncount         = columns.Count;
            List <T> result = new List <T>();    //声明一个要返回的对象泛型
            Type     type   = typeof(T);

            PropertyInfo[] propertys = type.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty);   //获取参数对象属性集合
            foreach (DataRow r in dt.Rows)
            {
                T t = new T();
                for (int i = 0; i < propertys.Length; i++)
                {
                    DataColumn column = columns[propertys[i].Name];
                    if (column != null && r[column] != null)
                    {
                        if (propertys[i].PropertyType == typeof(int))
                        {
                            propertys[i].SetValue(t, PublicMethod.GetInt(r[column]), null);
                        }
                        if (propertys[i].PropertyType == typeof(string))
                        {
                            propertys[i].SetValue(t, r[column].ToString(), null);
                        }
                        if (propertys[i].PropertyType == typeof(DateTime))
                        {
                            propertys[i].SetValue(t, PublicMethod.GetDateTime(r[column]), null);
                        }
                    }
                }
                result.Add(t);
            }
            return(result);
        }
Esempio n. 3
0
        public static DataTable GetPageWithSp(ProcCustomPage pcp, out int recordCount)
        {
            using (var conn = new SqlConnection(cs))
            {
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = pcp.Sp_PagerName;
                    cmd.InjectFrom(new SetParamsValues().IgnoreFields("sp_pagername"), pcp);

                    SqlParameter outputPara = new SqlParameter("@RecordCount", SqlDbType.Int);
                    outputPara.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(outputPara);

                    conn.Open();

                    using (var da = new SqlDataAdapter(cmd))
                    {
                        DataSet ds = new DataSet();
                        da.Fill(ds);
                        cmd.Parameters.Clear();
                        recordCount = PublicMethod.GetInt(outputPara.Value);
                        conn.Close();
                        return(ds.Tables[0]);
                    }
                }
            }
        }
Esempio n. 4
0
        public string InventorySync(List <SALES_ORDER_DATAMODEL> salesOrderDatas, List <SALESOUT_DATAMODEL> salesoutDatas, List <TP_INVENTORYMODEL> inventorys)
        {
            try
            {
                foreach (var model in salesOrderDatas)
                {
                    sales_order_dataModel newmodel = new sales_order_dataModel();
                    newmodel.fid                  = PublicMethod.GetInt(model.FID);
                    newmodel.Part_name            = PublicMethod.GetString(model.PART_NAME);
                    newmodel.PRIME_COMMODITY_NAME = PublicMethod.GetString(model.PRIME_COMMODITY_NAME);
                    newmodel.fqty                 = PublicMethod.GetDecimal(model.FQTY);
                    newmodel.ftime                = PublicMethod.GetDateTime(model.FTIME);
                    newmodel.funit                = PublicMethod.GetString(model.FUNIT);
                    //LogHelper.WriteLog(JsonHelper.ToJson(newmodel));
                    sales_order_dataDal.Instance.InsertEx(newmodel);
                }

                foreach (var model in salesoutDatas)
                {
                    salesout_dataModel newmodel = new salesout_dataModel();
                    newmodel.fid                  = PublicMethod.GetInt(model.FID);
                    newmodel.fdate                = PublicMethod.GetDateTime(model.FDATE);
                    newmodel.Part_name            = model.PART_NAME;
                    newmodel.PRIME_COMMODITY_NAME = model.PRIME_COMMODITY_NAME;
                    newmodel.fqty                 = PublicMethod.GetDecimal(model.FQTY);
                    newmodel.Shipping_date        = PublicMethod.GetDateTime(model.SHIPPING_DATE);
                    newmodel.funit                = model.FUNIT;
                    newmodel.COLOR_NO             = model.COLOR_NO;
                    // LogHelper.WriteLog(JsonHelper.ToJson(newmodel));
                    salesout_dataDal.Instance.InsertEx(newmodel);
                }

                foreach (var model in inventorys)
                {
                    TP_inventoryModel newmodel = new TP_inventoryModel();
                    newmodel.fid                  = PublicMethod.GetInt(model.FID);
                    newmodel.Part_name            = model.PART_NAME;
                    newmodel.PRIME_COMMODITY_NAME = model.PRIME_COMMODITY_NAME;
                    newmodel.fqty                 = PublicMethod.GetDecimal(model.FQTY);
                    newmodel.ftime                = PublicMethod.GetDateTime(model.FTIME);
                    newmodel.funit                = model.FUNIT;
                    //LogHelper.WriteLog(JsonHelper.ToJson(newmodel));
                    TP_inventoryDal.Instance.InsertEx(newmodel);
                }

                LogHelper.WriteLog("123123");

                return(JsonHelper.ToJson(new { errCode = 0, errMsg = "上传成功!" }));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 发货计划-输出接口
        /// </summary>
        /// <param name="icseout">发货计划主记录</param>
        /// <param name="icseoutentry">发货计划明细记录</param>
        /// <returns></returns>
        public string ICSEOUTBILLSync(List <V_ICSEOUTBILLMODEL> icseout, List <V_ICSEOUTBILLENTRYMODEL> icseoutentry)
        {
            try
            {
                if (icseout.Count > 0)
                {
                    int result = 0;
                    foreach (V_ICSEOUTBILLENTRYMODEL entrymodel in icseoutentry)
                    {
                        //普通开单
                        if (icseout[0].FBILLING_TYPE == 1)
                        {
                            //PLANBill_HuaNaiDal.Instance.DeleteWhere(new { FBILLNO = icseout[0].FBILLNO, FSYNCSTATUS = -3 });

                            PLANBill_HuaNaiDal.Instance.DeleteWhere(new { FBILLNO = icseout[0].FBILLNO, FENTRYID = entrymodel.FENTRYID });

                            PLANBill_HuaNaiModel newmodel = new PLANBill_HuaNaiModel();
                            newmodel.FBILLNO     = icseout[0].FBILLNO;
                            newmodel.FSTATUS     = 1;
                            newmodel.FSYNCSTATUS = 0;
                            newmodel.FACCOUNT    = icseout[0].FACCOUNT;
                            //newmodel.FPLATENUMBER =string.Format(@"{0}\{1}\{2}\{3}", icseout[0].FCARNUMBER, icseout[0].FEXPRESSCOMPANYNAME, icseout[0].FDELIVERERADDR, icseout[0].FPROJECTNAME) ;
                            newmodel.FPLATENUMBER      = icseout[0].FCARNUMBER;
                            newmodel.FDRIVER           = icseout[0].FDELIVERER;
                            newmodel.FDRPHONE          = icseout[0].FDELIVERERTEL;
                            newmodel.FCENTER_WAREHOUSE = icseout[0].FCENTER_WAREHOUSE;
                            newmodel.FIS_CONSIGN       = PublicMethod.GetInt(icseout[0].FIS_CONSIGN);
                            newmodel.FDELIVERY_METHOD  = icseout[0].FDELIVERY_METHODNUMBER;
                            newmodel.FENTRYID          = PublicMethod.GetInt(entrymodel.FENTRYID);
                            newmodel.FITEMID           = entrymodel.FITEMID;
                            newmodel.FSRCCODE          = entrymodel.FSRCCODE;
                            newmodel.FSRCNAME          = entrymodel.FSRCNAME;
                            newmodel.FSRCMODEL         = entrymodel.FSRCMODEL;
                            newmodel.FBATCHNO          = entrymodel.FBATCHNO;
                            newmodel.FCOLORNO          = entrymodel.FCOLORNO;
                            newmodel.FPRICE            = entrymodel.FACCOUNTPRICE;
                            newmodel.FAMOUNT           = entrymodel.FAMOUNT;
                            newmodel.FERR_MESSAGE      = entrymodel.FERR_MESSAGE;
                            newmodel.FAUDQTY           = entrymodel.FCOMMITQTY;
                            //newmodel.FCOMMITQTY = entrymodel.FCOMMITQTY;
                            newmodel.FREMARK      = icseout[0].FREMARK;
                            newmodel.FNEEDDATE    = icseout[0].FDELIVERDATE;
                            newmodel.FGRADE       = entrymodel.FLEVEL;
                            newmodel.FLINE_NOTE   = entrymodel.FDESCRIPTION;
                            newmodel.FPLANDESC    = icseout[0].FPLANDESC;
                            newmodel.FPURCHASE_NO = icseout[0].FPURCHASE_NO;
                            newmodel.FIS_CONSIGN  = icseout[0].FIS_CONSIGN;

                            result = PLANBill_HuaNaiDal.Instance.Insert(newmodel);
                        }

                        //托管库开单
                        if (icseout[0].FBILLING_TYPE == 2)
                        {
                            Customer_TG_Order_HuaNaiDal.Instance.DeleteWhere(new { FBILLNO = icseout[0].FBILLNO, FSYNCSTATUS = -3 });

                            Customer_TG_Order_HuaNaiModel newmodel = new Customer_TG_Order_HuaNaiModel();
                            newmodel.FBILLNO         = icseout[0].FBILLNO;
                            newmodel.FNEEDDATE       = icseout[0].FDELIVERDATE;
                            newmodel.CUSTOMER_NO     = icseout[0].FACCOUNT;
                            newmodel.CUST_REF        = icseout[0].FACCOUNT;
                            newmodel.CAR_NO          = icseout[0].FCARNUMBER;
                            newmodel.NOTE            = icseout[0].FPLANDESC;
                            newmodel.PART_NO         = entrymodel.FSRCCODE;
                            newmodel.LOCATION_NO     = entrymodel.FSTOCKNUMBER;
                            newmodel.WareHouse       = entrymodel.FSTOCK;
                            newmodel.LOT_BATCH_NO    = entrymodel.FBATCHNO;
                            newmodel.LOCATION_NO     = entrymodel.FLOCATION_NO;
                            newmodel.QUANTITY        = entrymodel.FCOMMITQTY;
                            newmodel.lineNote        = entrymodel.FDESCRIPTION;
                            newmodel.WAIV_DEV_REJ_NO = entrymodel.FWDR;
                            newmodel.FSYNCSTATUS     = 0;
                            newmodel.FENTRYID        = PublicMethod.GetInt(entrymodel.FENTRYID);

                            result = Customer_TG_Order_HuaNaiDal.Instance.Insert(newmodel);
                        }
                    }

                    if (result > 0)
                    {
                        trans_finishModel model = new trans_finishModel();
                        model.fbillno   = icseout[0].FBILLNO;
                        model.if_TGbill = (icseout[0].FBILLING_TYPE == 2);
                        trans_finishDal.Instance.Insert(model);

                        return(JsonHelper.ToJson(new { errCode = 0, errMsg = "上传成功!" }));
                    }
                }

                return(JsonHelper.ToJson(new { errCode = -1, errMsg = "上传失败!" }));
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                throw ex;
            }
        }