Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
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);
        }