Example #1
0
        public int addTran(VAN_OA.Model.JXC.Sell_OrderOutHouse model, VAN_OA.Model.EFrom.tb_EForm eform, List <Sell_OrderOutHouses> orders, out int MainId)
        {
            decimal total = 0;

            for (int i = 0; i < orders.Count; i++)
            {
                total += orders[i].GoodSellPriceTotal;
            }
            model.SellTotal = total;

            int id = 0;

            MainId = 0;
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;
                Sell_OrderOutHousesService OrdersSer = new Sell_OrderOutHousesService();

                TB_HouseGoodsService houseGoodsSer = new TB_HouseGoodsService();
                try
                {
                    objCommand.Parameters.Clear();
                    tb_EFormService eformSer = new tb_EFormService();
                    string          proNo    = eformSer.GetAllE_No("Sell_OrderOutHouse", objCommand);
                    model.ProNo = proNo;
                    eform.E_No  = proNo;

                    model.Status = eform.state;
                    id           = Add(model, objCommand);
                    MainId       = id;

                    eform.allE_id = id;
                    eformSer.Add(eform, objCommand);
                    for (int i = 0; i < orders.Count; i++)
                    {
                        orders[i].id = id;
                        OrdersSer.Add(orders[i], objCommand);

                        if (eform.state == "通过")
                        {
                            houseGoodsSer.OutHouse(orders[i].HouseID, orders[i].GooId, orders[i].GoodNum, orders[i].GoodPrice, objCommand);
                        }
                    }
                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(0);
                }
                return(id);
            }
        }
Example #2
0
        /// <summary>
        /// 获得数据列表(比DataSet效率高,推荐使用)
        /// </summary>
        public List <VAN_OA.Model.JXC.Sell_OrderOutHouse> GetListArray_ToBack(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   ");
            strSql.Append(" Sell_OrderOutHouse.Id,RuTime,Sell_OrderOutHouse.Supplier,Sell_OrderOutHouse.ProNo,Sell_OrderOutHouse.PONo,Sell_OrderOutHouse.POName,Sell_OrderOutHouse.SellTotal ");
            strSql.Append(" from Sell_OrderOutHouse left join Sell_OrderOutHouseBack on Sell_OrderOutHouse.ProNo=Sell_OrderOutHouseBack.SellProNo and Sell_OrderOutHouseBack.Status<>'不通过'");

            strSql.Append(" where Sell_OrderOutHouse.Status='通过' and Sell_OrderOutHouseBack.id is null " + strWhere);

            strSql.Append(" order by Sell_OrderOutHouse.Id desc");
            List <VAN_OA.Model.JXC.Sell_OrderOutHouse> list = new List <VAN_OA.Model.JXC.Sell_OrderOutHouse>();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        VAN_OA.Model.JXC.Sell_OrderOutHouse model = new VAN_OA.Model.JXC.Sell_OrderOutHouse();
                        object ojb;
                        ojb = dataReader["Id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Id = (int)ojb;
                        }
                        ojb = dataReader["RuTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.RuTime = (DateTime)ojb;
                        }
                        model.Supplier = dataReader["Supplier"].ToString();
                        model.ProNo    = dataReader["ProNo"].ToString();
                        model.PONo     = dataReader["PONo"].ToString();
                        model.POName   = dataReader["POName"].ToString();
                        ojb            = dataReader["SellTotal"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.SellTotal = Convert.ToDecimal(ojb);
                        }

                        list.Add(model);
                    }
                }
            }
            return(list);
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(VAN_OA.Model.JXC.Sell_OrderOutHouse model, SqlCommand objCommand)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Sell_OrderOutHouse set ");

            if (model.Remark != null)
            {
                strSql.Append("Remark='" + model.Remark + "',");
            }
            else
            {
                strSql.Append("Remark= null ,");
            }
            if (model.Status != null)
            {
                strSql.Append("Status='" + model.Status + "',");
            }
            if (model.FPNo != null)
            {
                strSql.Append("FPNo='" + model.FPNo + "',");
            }
            else
            {
                strSql.Append("FPNo= null ,");
            }
            if (model.DaiLi != null)
            {
                strSql.Append("DaiLi='" + model.DaiLi + "',");
            }
            else
            {
                strSql.Append("DaiLi= null ,");
            }
            if (model.SellTotal != null)
            {
                strSql.Append("SellTotal=" + model.SellTotal + ",");
            }

            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where Id=" + model.Id + "");
            objCommand.CommandText = strSql.ToString();
            objCommand.ExecuteNonQuery();
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VAN_OA.Model.JXC.Sell_OrderOutHouse GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   ");
            strSql.Append(" Sell_OrderOutHouse.Id,CreateUserId,CreateTime,RuTime,Supplier,DoPer,ChcekProNo,ProNo,PONo,POName,Remark ,tb_User.loginName as CreateName,Status,FPNo,DaiLi,IsPrint ,SellTotal");
            strSql.Append(" from Sell_OrderOutHouse left join tb_User on tb_User.id=CreateUserId ");
            strSql.Append(" where Sell_OrderOutHouse.Id=" + id + "");

            VAN_OA.Model.JXC.Sell_OrderOutHouse model = null;
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    if (dataReader.Read())
                    {
                        model = ReaderBind(dataReader);
                    }
                }
            }
            return(model);
        }
Example #5
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public VAN_OA.Model.JXC.Sell_OrderOutHouse ReaderBind(IDataReader dataReader)
        {
            VAN_OA.Model.JXC.Sell_OrderOutHouse model = new VAN_OA.Model.JXC.Sell_OrderOutHouse();
            object ojb;

            ojb = dataReader["Id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Id = (int)ojb;
            }
            ojb = dataReader["CreateUserId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateUserId = (int)ojb;
            }
            ojb = dataReader["CreateTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateTime = (DateTime)ojb;
            }
            ojb = dataReader["RuTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RuTime = (DateTime)ojb;
            }
            model.Supplier = dataReader["Supplier"].ToString();
            model.DoPer    = dataReader["DoPer"].ToString();

            model.ChcekProNo = dataReader["ChcekProNo"].ToString();
            model.ProNo      = dataReader["ProNo"].ToString();
            model.PONo       = dataReader["PONo"].ToString();
            model.POName     = dataReader["POName"].ToString();
            model.Remark     = dataReader["Remark"].ToString();
            ojb = dataReader["CreateName"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreateName = ojb.ToString();
            }

            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = ojb.ToString();
            }
            ojb = dataReader["FPNo"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FPNo = ojb.ToString();
            }
            ojb = dataReader["DaiLi"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DaiLi = ojb.ToString();
            }
            ojb = dataReader["IsPrint"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsPrint = Convert.ToBoolean(ojb);
            }

            ojb = dataReader["SellTotal"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SellTotal = Convert.ToDecimal(ojb);
            }


            return(model);
        }
Example #6
0
        /// <summary>
        /// 获取所有销售出库的单子(已经审核通过 并且在销售退货中没有退完的)
        /// </summary>
        public List <VAN_OA.Model.JXC.Sell_OrderOutHouse> GetListSell_OrderOutHouse_Sell_OrderInHouse_View(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   ");
            strSql.Append(" [Id] ,[CreateUserId]  ,[CreateTime],[RuTime],[Supplier],[DoPer],[ChcekProNo],[ProNo],[PONo],[POName],[Remark],[Status]");
            strSql.Append(" from Sell_OrderOutHouse_Sell_OrderInHouse_View ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            strSql.Append(" order by [CreateTime] desc ");
            List <VAN_OA.Model.JXC.Sell_OrderOutHouse> list = new List <VAN_OA.Model.JXC.Sell_OrderOutHouse>();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        VAN_OA.Model.JXC.Sell_OrderOutHouse model = new VAN_OA.Model.JXC.Sell_OrderOutHouse();
                        object ojb;
                        ojb = dataReader["Id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Id = (int)ojb;
                        }
                        ojb = dataReader["CreateUserId"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.CreateUserId = (int)ojb;
                        }
                        ojb = dataReader["CreateTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.CreateTime = (DateTime)ojb;
                        }
                        ojb = dataReader["RuTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.RuTime = (DateTime)ojb;
                        }
                        model.Supplier = dataReader["Supplier"].ToString();
                        model.DoPer    = dataReader["DoPer"].ToString();

                        model.ChcekProNo = dataReader["ChcekProNo"].ToString();
                        model.ProNo      = dataReader["ProNo"].ToString();
                        model.PONo       = dataReader["PONo"].ToString();
                        model.POName     = dataReader["POName"].ToString();
                        model.Remark     = dataReader["Remark"].ToString();
                        ojb = dataReader["Status"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Status = ojb.ToString();
                        }

                        list.Add(model);
                    }
                }
            }
            return(list);
        }
Example #7
0
        public bool updateTran(VAN_OA.Model.JXC.Sell_OrderOutHouse model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <Sell_OrderOutHouses> orders, string IDS)
        {
            decimal total = 0;

            for (int i = 0; i < orders.Count; i++)
            {
                total += orders[i].GoodSellPriceTotal;
            }
            model.SellTotal = total;

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;

                Sell_OrderOutHousesService OrdersSer = new Sell_OrderOutHousesService();
                //CG_POCaiService CaiSer = new CG_POCaiService();
                try
                {
                    objCommand.Parameters.Clear();
                    model.Status = eform.state;
                    Update(model, objCommand);
                    tb_EFormService eformSer = new tb_EFormService();
                    eformSer.Update(eform, objCommand);
                    tb_EFormsService eformsSer = new tb_EFormsService();
                    eformsSer.Add(forms, objCommand);
                    TB_HouseGoodsService houseGoodsSer = new TB_HouseGoodsService();

                    for (int i = 0; i < orders.Count; i++)
                    {
                        orders[i].id = model.Id;
                        //if (orders[i].IfUpdate == true && orders[i].Ids != 0)
                        //{

                        OrdersSer.Update(orders[i], objCommand);

                        //}
                        //else if (orders[i].Ids == 0)
                        //{
                        //    OrdersSer.Add(orders[i], objCommand);

                        //}
                    }
                    //if (IDS != "")
                    //{
                    //    IDS  = IDS.Substring(0, IDS.Length - 1);
                    //    OrdersSer.DeleteByIds(IDS, objCommand);
                    //}
                    for (int i = 0; i < orders.Count; i++)
                    {
                        if (eform.state == "通过")
                        {
                            houseGoodsSer.OutHouse(orders[i].HouseID, orders[i].GooId, orders[i].GoodNum, orders[i].GoodPrice, objCommand);
                        }
                    }

                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(false);
                }
            }

            return(true);
        }
Example #8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VAN_OA.Model.JXC.Sell_OrderOutHouse model, SqlCommand objCommand)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.CreateUserId != null)
            {
                strSql1.Append("CreateUserId,");
                strSql2.Append("" + model.CreateUserId + ",");
            }

            strSql1.Append("CreateTime,");
            strSql2.Append("getdate(),");

            if (model.RuTime != null)
            {
                strSql1.Append("RuTime,");
                strSql2.Append("'" + model.RuTime + "',");
            }
            if (model.Supplier != null)
            {
                strSql1.Append("Supplier,");
                strSql2.Append("'" + model.Supplier + "',");
            }
            if (model.DoPer != null)
            {
                strSql1.Append("DoPer,");
                strSql2.Append("'" + model.DoPer + "',");
            }

            if (model.ChcekProNo != null)
            {
                strSql1.Append("ChcekProNo,");
                strSql2.Append("'" + model.ChcekProNo + "',");
            }
            if (model.ProNo != null)
            {
                strSql1.Append("ProNo,");
                strSql2.Append("'" + model.ProNo + "',");
            }
            if (model.PONo != null)
            {
                strSql1.Append("PONo,");
                strSql2.Append("'" + model.PONo + "',");
            }
            if (model.POName != null)
            {
                strSql1.Append("POName,");
                strSql2.Append("'" + model.POName + "',");
            }
            if (model.Remark != null)
            {
                strSql1.Append("Remark,");
                strSql2.Append("'" + model.Remark + "',");
            }
            if (model.Status != null)
            {
                strSql1.Append("Status,");
                strSql2.Append("'" + model.Status + "',");
            }

            if (model.FPNo != null)
            {
                strSql1.Append("FPNo,");
                strSql2.Append("'" + model.FPNo + "',");
            }
            if (model.DaiLi != null)
            {
                strSql1.Append("DaiLi,");
                strSql2.Append("'" + model.DaiLi + "',");
            }

            if (model.SellTotal != null)
            {
                strSql1.Append("SellTotal,");
                strSql2.Append("" + model.SellTotal + ",");
            }

            strSql.Append("insert into Sell_OrderOutHouse(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");

            int result;

            objCommand.CommandText = strSql.ToString();
            object obj = objCommand.ExecuteScalar();

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }