Example #1
0
 private void UpdateSOVAT(SOVATInfo vatInfo)
 {
     new SOVATDac().Update(vatInfo);
 }
Example #2
0
        public int Insert(SOVATInfo oParam)
        {
            string sql = @"INSERT INTO SO_ValueAdded_Invoice
                            (
                            SOSysNo, CustomerSysNo, CompanyName,
                            TaxNum, CompanyAddress, CompanyPhone, BankAccount,
                            Memo,VATEMSFee
                            )
                            VALUES (
                            @SOSysNo, @CustomerSysNo, @CompanyName,
                            @TaxNum, @CompanyAddress, @CompanyPhone, @BankAccount,
                            @Memo,@VATEMSFee
                            )";

            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSOSysNo = new SqlParameter("@SOSysNo", SqlDbType.Int,4);
            SqlParameter paramCustomerSysNo = new SqlParameter("@CustomerSysNo", SqlDbType.Int,4);
            SqlParameter paramCompanyName = new SqlParameter("@CompanyName", SqlDbType.NVarChar,100);
            SqlParameter paramTaxNum = new SqlParameter("@TaxNum", SqlDbType.NVarChar,20);
            SqlParameter paramCompanyAddress = new SqlParameter("@CompanyAddress", SqlDbType.NVarChar,200);
            SqlParameter paramCompanyPhone = new SqlParameter("@CompanyPhone", SqlDbType.NVarChar,10);
            SqlParameter paramBankAccount = new SqlParameter("@BankAccount", SqlDbType.NVarChar,100);
            SqlParameter paramMemo = new SqlParameter("@Memo", SqlDbType.NVarChar,200);
            SqlParameter paramVATEMSFee = new SqlParameter("@VATEMSFee", SqlDbType.Decimal,9);

            if ( oParam.SOSysNo != AppConst.IntNull)
                paramSOSysNo.Value = oParam.SOSysNo;
            else
                paramSOSysNo.Value = System.DBNull.Value;
            if ( oParam.CustomerSysNo != AppConst.IntNull)
                paramCustomerSysNo.Value = oParam.CustomerSysNo;
            else
                paramCustomerSysNo.Value = System.DBNull.Value;
            if ( oParam.CompanyName != AppConst.StringNull)
                paramCompanyName.Value = oParam.CompanyName;
            else
                paramCompanyName.Value = System.DBNull.Value;
            if ( oParam.TaxNum != AppConst.StringNull)
                paramTaxNum.Value = oParam.TaxNum;
            else
                paramTaxNum.Value = System.DBNull.Value;
            if ( oParam.CompanyAddress != AppConst.StringNull)
                paramCompanyAddress.Value = oParam.CompanyAddress;
            else
                paramCompanyAddress.Value = System.DBNull.Value;
            if ( oParam.CompanyPhone != AppConst.StringNull)
                paramCompanyPhone.Value = oParam.CompanyPhone;
            else
                paramCompanyPhone.Value = System.DBNull.Value;
            if ( oParam.BankAccount != AppConst.StringNull)
                paramBankAccount.Value = oParam.BankAccount;
            else
                paramBankAccount.Value = System.DBNull.Value;
            if ( oParam.Memo != AppConst.StringNull)
                paramMemo.Value = oParam.Memo;
            else
                paramMemo.Value = System.DBNull.Value;
            if ( oParam.VATEMSFee != AppConst.DecimalNull)
                paramVATEMSFee.Value = oParam.VATEMSFee;
            else
                paramVATEMSFee.Value = System.DBNull.Value;

            cmd.Parameters.Add(paramSOSysNo);
            cmd.Parameters.Add(paramCustomerSysNo);
            cmd.Parameters.Add(paramCompanyName);
            cmd.Parameters.Add(paramTaxNum);
            cmd.Parameters.Add(paramCompanyAddress);
            cmd.Parameters.Add(paramCompanyPhone);
            cmd.Parameters.Add(paramBankAccount);
            cmd.Parameters.Add(paramMemo);
            cmd.Parameters.Add(paramVATEMSFee);

            return SqlHelper.ExecuteNonQuery(cmd);
        }
Example #3
0
 public void SaveVAT(SOVATInfo vatInfo)
 {
     if(vatInfo.SOSysNo==AppConst.IntNull)
         throw new BizException("The SO doesn't exist,can't save vat");
     string sql = @"select * from so_valueAdded_invoice where sosysno ="+vatInfo.SOSysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     if(Util.HasMoreRow(ds))
     {
         this.UpdateSOVAT(vatInfo);
     }
     else
     {
         this.InsertSOVAT(vatInfo);
     }
 }
Example #4
0
 private void map(SOVATInfo oParam, DataRow tempdr)
 {
     oParam.SysNo = Util.TrimIntNull(tempdr["SysNo"]);
     oParam.SOSysNo = Util.TrimIntNull(tempdr["SOSysNo"]);
     oParam.CustomerSysNo = Util.TrimIntNull(tempdr["CustomerSysNo"]);
     oParam.CompanyName = Util.TrimNull(tempdr["CompanyName"]);
     oParam.TaxNum = Util.TrimNull(tempdr["TaxNum"]);
     oParam.CompanyAddress = Util.TrimNull(tempdr["CompanyAddress"]);
     oParam.CompanyPhone = Util.TrimNull(tempdr["CompanyPhone"]);
     oParam.BankAccount = Util.TrimNull(tempdr["BankAccount"]);
     oParam.Memo = Util.TrimNull(tempdr["Memo"]);
     oParam.CreateTime = Util.TrimDateNull(tempdr["CreateTime"]);
     oParam.VATEMSFee = Util.TrimDecimalNull(tempdr["VATEMSFee"]);
 }
Example #5
0
 public SOVATInfo LoadSOVAT(int soSysNo)
 {
     string sql = "select * from so_valueadded_invoice where sosysno = "+soSysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     SOVATInfo oVAT = new SOVATInfo();
     if(Util.HasMoreRow(ds))
         map(oVAT,ds.Tables[0].Rows[0]);
     return oVAT;
 }
Example #6
0
 public int InsertSOVAT(SOVATInfo oParam)
 {
     return new SOVATDac().Insert(oParam);
 }
Example #7
0
        public void ImportSO()
        {
            if(!AppConfig.IsImportable)
                throw new BizException("IsImportable is false");
            string sqlMasterChk = "select top 1  * from SO_Master";
            DataSet dsMasterChk = SqlHelper.ExecuteDataSet(sqlMasterChk);
            if(Util.HasMoreRow(dsMasterChk))
                throw new BizException("The SO_Master is not empty");
            string sqlItemChk = "select top 1 * from so_item";
            DataSet dsItemChk = SqlHelper.ExecuteDataSet(sqlItemChk);
            if(Util.HasMoreRow(dsItemChk))
                throw new BizException("The SO_Item is not empty");
            string sqlCheckVAT = @"select top 1 * from so_valueAdded_invoice";
            DataSet dsCheckVAT = SqlHelper.ExecuteDataSet(sqlCheckVAT);
            if(Util.HasMoreRow(dsCheckVAT))
                throw new BizException("The VAT is not empty");
            string sqlCheckSaleRule = @"select top 1 * from so_salerule";
            DataSet dsCheckSaleRule = SqlHelper.ExecuteDataSet(sqlCheckSaleRule);
            if(Util.HasMoreRow(dsCheckSaleRule))
                throw new BizException("The SO_SaleRule is not empty");
            string sqlDataCleanUp = @"--����so����
                                      --ɾ���������soitem
                                      delete from ipp2003..so_item where sysno in (select si.sysno from ipp2003..so_item si left join ipp2003..so_master sm on si.sosysno = sm.sysno where sm.sysno is null)
                                      --ɾ��ͬһ����ͬһ��Ʒ���ظ���ϸ
                                      delete from ipp2003..so_item where sysno not in (select min(sysno) as sysno from ipp2003..so_item group by sosysno,productsysno having count(*)>1)
                                      and sosysno in (select sosysno from ipp2003..so_item group by sosysno,productsysno having count(*)>1)
                                      and productsysno in (select productsysno from ipp2003..so_item group by sosysno,productsysno having count(*)>1)
                                      --���¶����ֿ���0-->1
                                      update ipp2003..so_master set warehousesysno = 1 where warehousesysno = 0
                                      --���¶����ջ������ţ����Ϊ�������Ϊ�ͻ�ע����Ϣ�е��ջ��������
                                      update ipp2003..so_master set receiveareasysno = wi.shipareasysno from ipp2003..webuser_item wi where wi.webusersysno = ipp2003..so_master.sysno
                                      and (ipp2003..so_master.receiveareasysno is null or ipp2003..so_master.receiveareasysno = 1) and wi.shipareasysno is not null ";
            new ProductSaleTrendDac().Exec(sqlDataCleanUp);
            string sqlCheckSource = @"select * from ipp2003..so_item si left join ipp2003..so_master sm on si.sosysno = sm.sysno where sm.sysno is null;
                                      select sosysno,productsysno,count(*) as number from ipp2003..so_item group by sosysno,productsysno having count(*)>1;
                                      select soid,count(*) as number from ipp2003..so_master group by soid having count(*)>1;
                                      select * from ipp2003..so_master sm left join ipp2003..stock s on s.sysno = sm.warehousesysno where s.sysno is null;";
            DataSet dsCheckSource = SqlHelper.ExecuteDataSet(sqlCheckSource);
            foreach(DataTable dt in dsCheckSource.Tables)
            {
                if(Util.HasMoreRow(dt))
                    throw new BizException("The DataSource is uncorrect");
            }
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                //import master
                string sqlDefaultUser = @"select sysno from customer where CustomerID = 'UnknownUser'";
                DataSet dsDefaultUser = SqlHelper.ExecuteDataSet(sqlDefaultUser);
                string sqlDefaultPayType = @"select sysno from paytype where paytypeid = '0005'";
                DataSet dsDefaultPayType = SqlHelper.ExecuteDataSet(sqlDefaultPayType);
                string sqlMaster = @"select sm.sysno,soid,status,outtime,sodate as orderdate,deliverytime as DeliveryDate,ispremium,PremiumAmt,(case when sm.customsysno=-999 then "
                                     +dsDefaultUser.Tables[0].Rows[0][0]+@" else sm.customsysno end) as customersysno, shipprice, payprice, soamt, st.newsysno as shiptypesysno,
                                     isnull(pt.newsysno,"+dsDefaultPayType.Tables[0].Rows[0][0]+@") as paytypesysno,isprintinvoice as isvat,suwh.newsysno as outusersysno,receiveaddress,
                                     receivecontact, receivename,receivephone, receivezip, suft.newsysno as freightusersysno, audittime, suat.newsysno as auditusersysno,
                                     leaderaudittime as manageraudittime,sula.newsysno as  Managerauditusersysno,updatetime,suud.newsysno as updateusersysno,stock.newsysno as stocksysno,
                                     memo,note as invoicenote,suam.newsysno as allocatedmansysno,iswholesale,pointpay,cashamt as cashpay,isnull(susa.newsysno,0) as SalesManSysNo,PointAmt,
                                     isPrintPackageCover,deliverymemo,discountAmt,null as note, area.newsysno as receiveareasysno, null as receivecellphone
                                     from ipp2003..so_master sm
                                     left join ippconvert..shiptype st on st.oldsysno = sm.shiptypesysno
                                     left join ippconvert..paytype pt on pt.oldsysno = sm.paytypesysno
                                     left join ippconvert..sys_user suwh on suwh.oldsysno = sm.warehouseusersysno
                                     left join ippconvert..sys_user suft on suft.oldsysno = sm.freightusersysno
                                     left join ippconvert..sys_user suat on suat.oldsysno = sm.auditusersysno
                                     left join ippconvert..sys_user sula on sula.oldsysno = sm.leaderauditsysno
                                     left join ippconvert..sys_user suud on suud.oldsysno = sm.updateusersysno
                                     left join ippconvert..stock stock on stock.oldsysno = sm.warehousesysno
                                     left join ippconvert..sys_user suam on suam.oldsysno = sm.allocatedmansysno
                                     left join ippconvert..sys_user susa on susa.oldsysno = sm.salesmansysno
                                     left join ippconvert..area area on area.oldsysno = sm.receiveareasysno";
                DataSet dsMaster = SqlHelper.ExecuteDataSet(sqlMaster);
                if(Util.HasMoreRow(dsMaster))
                {
                    foreach(DataRow dr in dsMaster.Tables[0].Rows)
                    {
                        SOInfo oSOMaster = new SOInfo();
                        this.map(oSOMaster,dr);
                        new SODac().InsertMaster(oSOMaster);
                    }
                }
                //import item
                string sqlItem = @"select 1 as sysno,sosysno,pb.newsysno as productsysno,orderprice,price,(case when cost=-999 then 0 else isnull(cost,0) end) as cost,quantity,weight,
                                   (case when returnpoint = -999 then 0 else isnull(returnpoint,0) end) as point,
                                   (case when ltrim(rtrim(replace(warranty,CHAR(13)+char(10),'')))='' then '��' else isnull(warranty,'��') end) as warranty ,pointstatus as pointtype,discountamt,
                                   getdate() as createtime,0 as producttype,null as giftsysno
                                   from ipp2003..so_item si
                                   left join ippConvert..productbasic pb on pb.oldsysno = si.productsysno";
                DataSet dsItem = SqlHelper.ExecuteDataSet(sqlItem);
                if(Util.HasMoreRow(dsItem))
                {
                    foreach(DataRow drItem in dsItem.Tables[0].Rows)
                    {
                        SOItemInfo oSOItem = new SOItemInfo();
                        this.map(oSOItem,drItem);
                        new SODac().InsertItem(oSOItem);
                    }
                }
                //import VAT
                string sqlVATCleanUp = @"--������Ϣ��ȫ����Ʊ��¼
                                         update ipp2003..sale_value_added_invoice set taxsignnumber = '��Ϣ��ȫ' where ltrim(rtrim(replace(taxsignnumber,CHAR(13)+char(10),''))) = ''
              							 update ipp2003..sale_value_added_invoice set companyaddress = '��Ϣ��ȫ' where ltrim(rtrim(replace(companyaddress,CHAR(13)+char(10),''))) = ''
                                         update ipp2003..sale_value_added_invoice set companyphone = '��Ϣ��ȫ' where ltrim(rtrim(replace(companyphone,CHAR(13)+char(10),''))) = ''
                                         update ipp2003..sale_value_added_invoice set bankAndAccount = '��Ϣ��ȫ' where ltrim(rtrim(replace(bankAndAccount,CHAR(13)+char(10),''))) = ''
                                         update ipp2003..sale_value_added_invoice set companyname = '��Ϣ��ȫ' where ltrim(rtrim(replace(companyname,CHAR(13)+char(10),''))) = ''";
                new ProductSaleTrendDac().Exec(sqlVATCleanUp);
                string sqlVAT = @"select 1 as sysno,sosysno,customsysno as customersysno,CompanyName,TaxSignNumber as TaxNum,CompanyAddress,CompanyPhone,BankAndAccount as bankaccount,Memo,getdate() as createtime
                                  from ipp2003..sale_value_added_invoice sva";
                DataSet dsVAT =  SqlHelper.ExecuteDataSet(sqlVAT);
                if(Util.HasMoreRow(dsVAT))
                {
                    foreach(DataRow drVAT in dsVAT.Tables[0].Rows)
                    {
                        SOVATInfo oVAT = new SOVATInfo();
                        map(oVAT,drVAT);
                        InsertSOVAT(oVAT);
                    }
                }
                //import SaleRule
                string sqlSaleRule = @"select 1 as sysno,sosysno,discountdescription as salerulename,discountamt as discount,discounttimes as times,memo as note,
                                       srm.newsysno as salerulesysno,getdate() as createtime
                                       from ipp2003..so_discount sd
                                       inner join ippconvert..salerulemaster srm on srm.oldsysno = sd.salerulesysno";
                DataSet dsSaleRule = SqlHelper.ExecuteDataSet(sqlSaleRule);
                if(Util.HasMoreRow(dsSaleRule))
                {
                    foreach(DataRow drSaleRule in dsSaleRule.Tables[0].Rows)
                    {
                        SOSaleRuleInfo oSaleRule = new SOSaleRuleInfo();
                        map(oSaleRule,drSaleRule);
                        InsertSOSaleRule(oSaleRule);
                    }
                }
                //insert sequence
                string sqlMaxSysNo = @"select max(sysno) as sysno from so_master";
                DataSet dsMaxSysNo = SqlHelper.ExecuteDataSet(sqlMaxSysNo);
                int n = 0;
                while(n<Util.TrimIntNull(dsMaxSysNo.Tables[0].Rows[0][0]))
                {
                    n = SequenceDac.GetInstance().Create("SO_Sequence");
                }
                scope.Complete();
            }
        }
Example #8
0
 //        public Hashtable GetDistinctVATList(int customerSysNo)
 //        {
 //            string sql = @"select distinct null as sosysno,null as customersysno,companyname,taxnum,companyaddress,companyphone,bankaccount,null as memo,null as createtime
 //                           from so_valueadded_invoice
 //                           where customersysno ="+customerSysNo;
 //            DataSet ds = SqlHelper.ExecuteDataSet(sql);
 //            DataTable dt = ds.Tables[0];
 //            DataColumn dc = new DataColumn("SysNo",typeof(System.Int32));
 //            dt.Columns.Add(dc);
 //            Hashtable ht = new Hashtable();
 //            int n = 0 ;
 //            if(dt.Rows.Count>0)
 //            {
 //                foreach(DataRow dr in dt.Rows)
 //                {
 //                    dr["SysNo"] = n;
 //                    n++;
 //                    SOVATInfo vatInfo = new SOVATInfo();
 //                    this.map(vatInfo,dr);
 //                    ht.Add(vatInfo.SysNo,vatInfo);
 //                }
 //            }
 //            return ht;
 //        }
 //2007-01-21 lucky
 public Hashtable GetDistinctVATList(int customerSysNo)
 {
     string sql = @"select distinct null as sosysno,null as customersysno,companyname,taxnum,companyaddress,companyphone,bankaccount,null as memo,null as createtime,VATEMSFee
                    from so_valueadded_invoice
                    where customersysno ="+customerSysNo;
     DataSet ds = SqlHelper.ExecuteDataSet(sql);
     DataTable dt = ds.Tables[0];
     DataColumn dc = new DataColumn("SysNo",typeof(System.Int32));
     dt.Columns.Add(dc);
     Hashtable ht = new Hashtable();
     int n = 0 ;
     if(dt.Rows.Count>0)
     {
         foreach(DataRow dr in dt.Rows)
         {
             dr["SysNo"] = n;
             n++;
             SOVATInfo vatInfo = new SOVATInfo();
             this.map(vatInfo,dr);
             ht.Add(vatInfo.SysNo,vatInfo);
         }
     }
     return ht;
 }
Example #9
0
        /// <summary>
        /// 确认无误提交订单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckLimitedQtyProduct())
                    return;
                bool saveSOInfo = this.SaveSO();
                if (saveSOInfo == false)
                    return;
                soInfo.SalesManSysNo = AppConst.IcsonSalesMan;
                ////记录浩方订单
                //if (Session["LinkSource"] != null && Session["LinkSource"] as string == AppConfig.PartnerLinkSource)
                //{
                //    soInfo.SalesManSysNo = int.Parse(AppConfig.PartnerSysNo);
                //}
                //检验客户一分钟内是否有订单生成,防止重复下订单
                if (!SaleManager.GetInstance().SOCreatePreCheck(soInfo.CustomerSysNo))
                {
                    this.ShowMsg("请不要在1分钟之内重复下单。请到帐户中心查看您的订单");
                    return;
                }

                if (chkInvoice.Checked == true)
                {
                    if (chkInvoice.Checked == true)
                        vatInfo.Style.Add("display", "block");
                    else
                        vatInfo.Style.Add("display", "none");
                    if (txtCompanyName.Text.Trim() == AppConst.StringNull)
                    {
                        this.ShowMsg("开票公司名称不能为空!");
                        return;
                    }
                    if (txtCompanyAddr.Text.Trim() == AppConst.StringNull)
                    {
                        this.ShowMsg("开票公司地址不能为空!");
                        return;
                    }
                    if (txtCompanyPhone.Text.Trim() == AppConst.StringNull)
                    {
                        this.ShowMsg("开票公司电话不能为空!");
                        return;
                    }
                    if (txtBankAndAccount.Text.Trim() == AppConst.StringNull)
                    {
                        this.ShowMsg("开票开户银行及帐号不能为空!");
                        return;
                    }
                    if (txtTaxNum.Text.Trim() == AppConst.StringNull)
                    {
                        this.ShowMsg("开票公司税务登记号不能为空!");
                        return;
                    }

                    soInfo.IsVAT = (int)AppEnum.YNStatus.Yes;
                    soInfo.RequestInvoiceTime = DateTime.Now;
                    soInfo.RequestInvoiceType = (int)AppEnum.InvoiceType.SpecialVATInvoice;
                    soInfo.InvoiceStatus = (int)AppEnum.SOInvoiceStatus.InvoiceAbsent;
                }

                #region
                bool payTapyCheck = false;
                bool shipTypeCheck = false;

                foreach (DataGridItem dgItem in this.dgShipType.Items)
                {
                    RadioButton rdo = dgItem.FindControl("rdoSelectShipType") as RadioButton;
                    if (rdo.Checked)
                    {
                        soInfo.ShipTypeSysNo = Int32.Parse(dgShipType.DataKeys[dgItem.ItemIndex].ToString());
                        shipTypeCheck = true;
                        break;
                    }
                }
                if (chkIsPremium.Checked)
                {
                    soInfo.IsPremium = (int)AppEnum.YNStatus.Yes;
                }
                else
                    soInfo.IsPremium = (int)AppEnum.YNStatus.No;

                if (!shipTypeCheck)
                {
                    ShowMsg("您还没有选择配送方式");
                    return;
                }

                foreach (DataGridItem dgItem in this.dgPayType.Items)
                {
                    RadioButton rdo = dgItem.FindControl("rdoSelectPayType") as RadioButton;
                    if (rdo.Checked)
                    {
                        soInfo.PayTypeSysNo = Int32.Parse(dgPayType.DataKeys[dgItem.ItemIndex].ToString());
                        payTapyCheck = true;
                        break;
                    }
                }
                if (!payTapyCheck)
                {
                    this.ShowMsg("您还没有选择支付方式");
                    return;
                }

                soInfo.IsPremium = (int)AppEnum.YNStatus.No;
                soInfo.IsVAT = (int)AppEnum.YNStatus.No;
                soInfo.IsWholeSale = (int)AppEnum.YNStatus.No;
                soInfo.VATEMSFee = 0;
                soInfo.VatInfo.VATEMSFee = 0;
                soInfo.FreeShipFeePay = 0;

                #endregion

                soInfo.DeliveryDate = DateTime.Today;
                oSession.sSO = soInfo;
                SaleManager.GetInstance().CreateSO(soInfo);

                //if (soInfo.CouponCode.Length > 0 && soInfo.CouponAmt > 0 && soInfo.CouponType == 1) //宽带山
                //{
                //    try
                //    {
                //        string url = "http://club.pchome.net/union/icson/checkHashCode.php?action=1&code=" + soInfo.CouponCode;
                //        System.Net.WebClient wc = new System.Net.WebClient();
                //        System.IO.Stream stream = wc.OpenRead(url);
                //        wc.Dispose();
                //        stream.Close();
                //    }
                //    catch { }
                //}

                oSession.sCustomer = CustomerManager.GetInstance().Load(oSession.sCustomer.SysNo);
                try
                {
                    LogInfo log = new LogInfo();
                    log.OptIP = Request.UserHostAddress;
                    log.OptTime = DateTime.Now;
                    log.TicketSysNo = soInfo.SysNo;
                    log.TicketType = (int)AppEnum.LogType.Sale_SO_Create;
                    log.OptUserSysNo = soInfo.SalesManSysNo;
                    LogManager.GetInstance().Write(log);
                    SaleManager.GetInstance().SendEmail(soInfo, (int)AppEnum.SOEmailType.CreateSO);
                }
                catch (Exception ex)
                {
                    ErrorLog.GetInstance().Write(ex.Message);
                }
                //更新增票信息
                if (chkInvoice.Checked == true)
                {
                    try
                    {
                        SOVATInfo vat = new SOVATInfo();
                        vat.SOSysNo = soInfo.SysNo;
                        vat.BankAccount = txtBankAndAccount.Text.Trim();
                        vat.TaxNum = txtTaxNum.Text.Trim();
                        vat.CompanyAddress = txtCompanyAddr.Text.Trim();
                        vat.CompanyName = txtCompanyName.Text.Trim();
                        vat.CompanyPhone = txtCompanyPhone.Text.Trim();
                        vat.CustomerSysNo = oSession.sCustomer.SysNo;
                        vat.CreateTime = DateTime.Now;
                        vat.Memo = txtOthers.Text.Trim();
                        SaleManager.GetInstance().InsertSOVAT(vat);
                    }
                    catch
                    {
                        this.ShowMsg("增票信息更新失败,请联系MMMbuy.cn ");
                    }
                }

                //订单生成成功,清除购物车以及赠品信息
                CartManager.GetInstance().ClearCart();
                oSession.GiftHash.Clear();
                //转到支付页面
                PayTypeInfo ptInfo = ASPManager.GetInstance().LoadPayType(soInfo.PayTypeSysNo);
                if (ptInfo.PaymentPage != string.Empty)
                {
                    //Response.Redirect(ptInfo.PaymentPage + "?id=" + soInfo.SysNo.ToString() + "&sono=" + soInfo.SOID + "&soamt=" + SaleManager.GetInstance().GetEndMoney(soInfo).ToString(AppConst.DecimalFormat) + "&sodate=" + soInfo.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"));
                    try
                    {
                        //if (Request.Cookies["EqifaInfo"] != null && Request.Cookies["EqifaInfo"].Value != null && Request.Cookies["EqifaInfo"].Value.Length > 0)
                        //{
                        //    string merchant_id = "icson"; //广告主在EQIFA的帐号名
                        //    string eqifa_user_id = oSession.sCustomer.CustomerID; //会员帐号名称
                        //    string eqifa_user_name = oSession.sCustomer.CustomerName; //会员真实姓名
                        //    string eqifa_o_cd = soInfo.SysNo.ToString(); //用户订单号

                        //    string eqifa_p_cd = "";                        //一种商品编号
                        //    string eqifa_p_cnt = "1";			           //一种商品数量
                        //    string eqifa_p_price = soInfo.SOAmt.ToString();//一种商品价格
                        //    string eqifa_p_ccd = "";	                   //一种商品分类编号

                        //    string eqifa_info = Request.Cookies["EqifaInfo"].Value;
                        //    eqifa_info = Server.UrlDecode(eqifa_info);

                        //    if (eqifa_info.Replace("'", "''").Length != 0)
                        //    {
                        //        string eqifa_log = "http://service.eqifa.com/purchase_cps.aspx?a_id=" + eqifa_info;
                        //        eqifa_log += "&m_id=" + merchant_id + "&mbr_id=" + eqifa_user_id + "(" + eqifa_user_name + ")";
                        //        eqifa_log += "&o_cd=" + eqifa_o_cd + "&p_cd=" + eqifa_p_cd;
                        //        eqifa_log += "&p_cnt=" + eqifa_p_cnt + "&p_price=" + eqifa_p_price + "&p_ccd=" + eqifa_p_ccd;
                        //        eqifa_log = "<script src='" + eqifa_log + "'></script>";

                        //        //Response.Write(eqifa_log);
                        //        //Response.Write("<script src='http://icson-mis.3322.org/Temp.aspx?id=" + soInfo.SOID + "'></script>");

                        //        EqifaLogInfo eInfo = new EqifaLogInfo();
                        //        eInfo.SOSysNo = soInfo.SysNo;
                        //        eInfo.ProductSysNo = 1;
                        //        eInfo.Quantity = 1;
                        //        eInfo.Price = soInfo.SOAmt;
                        //        eInfo.EqifaLog = eqifa_log;

                        //        EqifaLogManager.GetInstance().Insert(eInfo);
                        //    }
                        //}
                        if (Request.Cookies["LSInfo"] != null && Request.Cookies["LSInfo"].Value != null && Request.Cookies["LSInfo"].Value.Length > 0)
                        {
                            EqifaLogInfo eInfo = new EqifaLogInfo();
                            eInfo.SOSysNo = soInfo.SysNo;
                            eInfo.ProductSysNo = 1;
                            eInfo.Quantity = 1;
                            eInfo.Price = soInfo.SOAmt;
                            eInfo.EqifaLog = Request.Cookies["LSInfo"].Value;

                            EqifaLogManager.GetInstance().Insert(eInfo);
                        }
                        else if (Session["LinkSource"] != null && Session["LinkSource"].ToString().Length > 0 && Session["LinkSource"].ToString().Trim().IndexOf("www.ICSON.com") == -1)
                        {
                            EqifaLogInfo eInfo = new EqifaLogInfo();
                            eInfo.SOSysNo = soInfo.SysNo;
                            eInfo.ProductSysNo = 1;
                            eInfo.Quantity = 1;
                            eInfo.Price = soInfo.SOAmt;
                            eInfo.EqifaLog = Session["LinkSource"].ToString().Trim();

                            EqifaLogManager.GetInstance().Insert(eInfo);
                        }
                    }
                    finally
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", "<script>location.href='" + ptInfo.PaymentPage + "?id=" + soInfo.SysNo.ToString() + "&sono=" + soInfo.SOID + "&soamt=" + SaleManager.GetInstance().GetEndMoney(soInfo).ToString(AppConst.DecimalFormat) + "&sodate=" + soInfo.OrderDate.ToString("yyyy-MM-dd HH:mm:ss") + "'</script>");
                    }
                }
                else
                {
                    Response.Redirect("../CustomError.aspx?msg=页面转向时发生错误!但是订单已经成功生成,订单号是:" + soInfo.SOID + "!");
                }
            }
            catch (BizException be)
            {
                if (be.Message.IndexOf("inventory: qty is not enough") != -1)
                {
                    this.ShowMsg("库存不足,请返回购物车重试");
                }
                else if (be.Message.IndexOf("inventory_stock: qty is not enough") != -1)
                {
                    this.ShowMsg("库存不足,请返回购物车重试");
                }
                else if (be.Message.IndexOf("客户积分更新失败") != -1)
                {
                    this.ShowMsg("您的积分不足,不能支付");
                }
                else
                {
                    this.ShowMsg(be.Message);
                }
            }
            catch (Exception ex)
            {
                ErrorLog.GetInstance().Write("订单生成失败:" + ex.Message);
                this.ShowMsg("订单生成失败,请重试或者电话联系MMMbuy.cn ");
            }
        }