Пример #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.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);
            }
        }
Пример #3
0
        public bool updateTran(VAN_OA.Model.JXC.Sell_OrderFP model, VAN_OA.Model.EFrom.tb_EForm eform,
                               tb_EForms forms, List <Sell_OrderFPs> orders, string IDS, bool isBackUp, bool isBackUpInvoice)
        {
            //判断是否是删除 -销售发票删除
            if (eform.proId == 37)
            {
                using (SqlConnection conn = DBHelp.getConn())
                {
                    conn.Open();
                    SqlTransaction tan        = conn.BeginTransaction();
                    SqlCommand     objCommand = conn.CreateCommand();
                    objCommand.Transaction = tan;
                    try
                    {
                        objCommand.Parameters.Clear();
                        model.Status = eform.state;
                        if (eform.state == "不通过")
                        {
                            model.Status = "通过";
                        }
                        UpdateToDelete(model, objCommand);
                        tb_EFormService eformSer = new tb_EFormService();
                        eformSer.Update(eform, objCommand, isBackUp);
                        tb_EFormsService eformsSer = new tb_EFormsService();
                        eformsSer.Add(forms, objCommand);

                        if (eform.state == "通过")
                        {
                            //删除发票签回单(如果有)
                            string deleteFPBack = string.Format("delete tb_EForms where e_Id in (select id from tb_EForm where proId=29 and allE_id in (select id from Sell_OrderFPBack where PId={0}));", model.Id);
                            deleteFPBack += string.Format("delete tb_EForm where proId=29 and allE_id in (select id from Sell_OrderFPBack where PId={0});", model.Id);
                            deleteFPBack += string.Format("delete Sell_OrderFPBacks  where Id in (select id from Sell_OrderFPBack where PId={0});delete Sell_OrderFPBack  where PId={0};", model.Id);

                            objCommand.CommandText = deleteFPBack;
                            objCommand.ExecuteNonQuery();

                            //删除发票删除单
                            string deleteFPDelete = string.Format("delete tb_EForms where e_Id in (select id from tb_EForm where proId in (26,34,37) and allE_id={0});", model.Id);
                            deleteFPDelete        += string.Format("delete tb_EForm where proId in (26,34,37) and allE_id={0};", model.Id);
                            objCommand.CommandText = deleteFPDelete;
                            objCommand.ExecuteNonQuery();

                            //删除发票单
                            string DeleteAll = string.Format(@"declare @oldFPNo  varchar(500);declare @oldPONo  varchar(500);
select top 1  @oldFPNo=FPNo,@oldPONo=PONo from Sell_OrderFP where id={0}
update  CG_POOrder set FPTotal=replace( FPTotal, @oldFPNo+'/','')
where PONo  in (select PONo from Sell_OrderFP where id={0}) and ifzhui=0;", model.Id);

                            Dal.EFrom.tb_EFormService efromSer = new VAN_OA.Dal.EFrom.tb_EFormService();
                            //var efromModel = efromSer.GetModel(Convert.ToInt32(model.Id));
                            //if (efromModel.state == "通过")
                            //{
                            DeleteAll += "update CG_POOrder set POStatue3='' where PONo=@oldPONo;";
                            //}

                            DeleteAll += string.Format("delete from Sell_OrderFP where id={0};delete from Sell_OrderFPs where id={0}; ", model.Id);

                            objCommand.CommandText = DeleteAll;
                            objCommand.ExecuteNonQuery();
                        }
                        tan.Commit();
                    }
                    catch (Exception)
                    {
                        tan.Rollback();
                        return(false);
                    }
                }
                if (eform.state == "通过")
                {
                    new Sell_OrderFPBackService().SellFPOrderBackUpdatePoStatus(model.PONo);
                    new VAN_OA.Dal.JXC.CG_POOrdersService().GetListArrayToFpsAndUpdatePoStatue(model.PONo, "通过");
                }
            }
            else
            {
                using (SqlConnection conn = DBHelp.getConn())
                {
                    conn.Open();
                    SqlTransaction tan        = conn.BeginTransaction();
                    SqlCommand     objCommand = conn.CreateCommand();
                    objCommand.Transaction = tan;

                    string backUpPoNos = "";
                    if (isBackUp)
                    {
                        BackUpFPInfoService backUpSer = new BackUpFPInfoService();
                        backUpPoNos = backUpSer.BackUp(model.Id, objCommand);
                    }
                    //最后进行 删除 到款单 ,以及发票签回单& 备份
                    if (isBackUpInvoice && eform.state == "通过")
                    {
                        BackUpFPInfoService backUpSer = new BackUpFPInfoService();
                        backUpPoNos = backUpSer.BackUpOthers(model.Id, objCommand, model.InvoiceNowGuid);
                    }
                    //CG_POOrdersService OrdersSer = new CG_POOrdersService();
                    //CG_POCaiService CaiSer = new CG_POCaiService();
                    try
                    {
                        decimal total = 0;
                        foreach (var m in orders)
                        {
                            total += m.GoodSellPriceTotal;
                        }
                        model.Total = total;
                        System.Collections.Hashtable hs = new System.Collections.Hashtable();
                        objCommand.Parameters.Clear();
                        model.Status = eform.state;
                        Update(model, objCommand);
                        tb_EFormService eformSer = new tb_EFormService();
                        eformSer.Update(eform, objCommand, isBackUp);
                        tb_EFormsService eformsSer = new tb_EFormsService();
                        eformsSer.Add(forms, objCommand);
                        TB_HouseGoodsService houseGoodsSer = new TB_HouseGoodsService();
                        Sell_OrderFPsService OrdersSer     = new Sell_OrderFPsService();
                        if (isBackUp)
                        {
                            //删除之前的数据
                            objCommand.CommandText = string.Format("delete from Sell_OrderFPs where id=" + model.Id);
                            objCommand.ExecuteNonQuery();

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

                                if (eform.state == "通过")
                                {
                                    if (!hs.Contains(orders[i].SellOutOrderId))
                                    {
                                        hs.Add(orders[i].SellOutOrderId, null);
                                    }
                                }
                            }
                        }


                        //foreach (var key in hs.Keys)
                        //{
                        //    //更改销售订单的发票号
                        //    string sql = string.Format("update Sell_OrderOutHouse set FPNo=FPNo+'{0}/' where ProNo='{1}'", model.FPNo, key);
                        //    objCommand.CommandText = sql;
                        //    objCommand.ExecuteNonQuery();
                        if (eform.state == "通过")
                        {
                            //更改项目订单的发票号
                            string sql = string.Format("update CG_POOrder set FPTotal=isnull(FPTotal,'')+'{0}/' where PONo='{1}' and ifzhui=0 ", model.FPNo, model.PONo);
                            objCommand.CommandText = sql;
                            objCommand.ExecuteNonQuery();
                        }
                        //}

                        //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);
                        //}


                        tan.Commit();


                        if (backUpPoNos != "")
                        {
                            foreach (string pono in backUpPoNos.Split(','))
                            {
                                if (!string.IsNullOrEmpty(pono))
                                {
                                    new Sell_OrderFPBackService().SellFPOrderBackUpdatePoStatus(pono);
                                    new CG_POOrderService().GetOrder_ToInvoiceAndUpdatePoStatus(pono);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        tan.Rollback();
                        return(false);
                    }
                }
            }
            return(true);
        }
        public bool updateTran(VAN_OA.Model.JXC.Sell_OrderInHouse model, VAN_OA.Model.EFrom.tb_EForm eform, tb_EForms forms, List <Sell_OrderInHouses> orders, string IDS)
        {
            decimal total = 0;

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

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlTransaction tan        = conn.BeginTransaction();
                SqlCommand     objCommand = conn.CreateCommand();
                objCommand.Transaction = tan;
                Sell_OrderInHousesService OrdersSer = new Sell_OrderInHousesService();
                //CG_POOrdersService OrdersSer = new CG_POOrdersService();
                //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++)
                    {
                        if (orders[i].GoodPriceSecond != 0)
                        {
                            orders[i].id = model.Id;


                            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 == "通过")
                        {
                            if (orders[i].GoodPriceSecond != 0)
                            {
                                houseGoodsSer.InHouse(orders[i].HouseID, orders[i].GooId, orders[i].GoodNum, orders[i].GoodPriceSecond, objCommand);
                            }
                            else
                            {
                                houseGoodsSer.InHouse(orders[i].HouseID, orders[i].GooId, orders[i].GoodNum, orders[i].GoodPrice, objCommand);
                            }
                        }
                    }

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

            return(true);
        }