예제 #1
0
        public int addTran(VAN_OA.Model.JXC.CAI_OrderInHouse model, VAN_OA.Model.EFrom.tb_EForm eform, List <CAI_OrderInHouses> orders, SqlCommand objCommand)
        {
            int id = 0;


            CAI_OrderInHousesService OrdersSer = new CAI_OrderInHousesService();

            TB_HouseGoodsService houseGoodsSer = new TB_HouseGoodsService();

            objCommand.Parameters.Clear();
            tb_EFormService eformSer = new tb_EFormService();
            string          proNo    = eformSer.GetAllE_No("CAI_OrderInHouse", objCommand);

            model.ProNo = proNo;
            eform.E_No  = proNo;

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


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

                if (eform.state == "通过")
                {
                    houseGoodsSer.InHouse(model.HouseID, orders[i].GooId, orders[i].GoodNum, orders[i].GoodPrice, objCommand);
                }
            }

            return(id);
        }
예제 #2
0
        public int addTran(VAN_OA.Model.JXC.CAI_OrderInHouse model, VAN_OA.Model.EFrom.tb_EForm eform, List <CAI_OrderInHouses> orders, out int MainId)
        {
            int id = 0;

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

                TB_HouseGoodsService houseGoodsSer = new TB_HouseGoodsService();
                try
                {
                    objCommand.Parameters.Clear();
                    tb_EFormService eformSer = new tb_EFormService();
                    string          proNo    = eformSer.GetAllE_No("CAI_OrderInHouse", 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.InHouse(model.HouseID, orders[i].GooId, orders[i].GoodNum, orders[i].GoodPrice, objCommand);
                        }
                    }
                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(0);
                }
                return(id);
            }
        }