Example #1
0
        public bool updateTran(VAN_OA.Model.JXC.Sell_OrderOutHouseBack model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <Sell_OrderOutHouseBacks> 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_OrderOutHouseBacksService OrdersSer = new Sell_OrderOutHouseBacksService();
                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);

                    //====删除所有子单据
                    string delete = "delete from Sell_OrderOutHouseBacks where id=" + model.Id;
                    objCommand.CommandText = delete;
                    objCommand.ExecuteNonQuery();
                    //====

                    for (int i = 0; i < orders.Count; i++)
                    {
                        orders[i].id = model.Id;
                        OrdersSer.Add(orders[i], objCommand);
                    }

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

            return(true);
        }
Example #2
0
        public int addTran(VAN_OA.Model.JXC.Sell_OrderOutHouseBack model, VAN_OA.Model.EFrom.tb_EForm eform, List <Sell_OrderOutHouseBacks> 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_OrderOutHouseBacksService OrdersSer     = new Sell_OrderOutHouseBacksService();
                TB_HouseGoodsService           houseGoodsSer = new TB_HouseGoodsService();
                try
                {
                    objCommand.Parameters.Clear();
                    tb_EFormService eformSer = new tb_EFormService();
                    string          proNo    = eformSer.GetAllE_No("Sell_OrderOutHouseBack", 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);
                    }
                    tan.Commit();
                }
                catch (Exception)
                {
                    tan.Rollback();
                    return(0);
                }
                return(id);
            }
        }