Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public string Update(UFIDA.U8.UAP.CustomApp.ControlForm.Model._发票_sap model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update _发票_sap set ");

            if (model.金税发票号码 != null)
            {
                strSql.Append("金税发票号码='" + model.金税发票号码 + "',");
            }
            else
            {
                strSql.Append("金税发票号码= null ,");
            }

            if (model.修改人 != null)
            {
                strSql.Append("修改人='" + model.修改人 + "',");
            }
            else
            {
                strSql.Append("修改人= null ,");
            }
            strSql.Append("修改时间 = getdate(),");

            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where iID=" + model.iID + "");
            return(strSql.ToString());
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(UFIDA.U8.UAP.CustomApp.ControlForm.Model._发票_sap model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.销售组织 != null)
            {
                strSql1.Append("销售组织,");
                strSql2.Append("'" + model.销售组织 + "',");
            }
            if (model.发票号码 != null)
            {
                strSql1.Append("发票号码,");
                strSql2.Append("'" + model.发票号码 + "',");
            }
            if (model.发票类型 != null)
            {
                strSql1.Append("发票类型,");
                strSql2.Append("'" + model.发票类型 + "',");
            }
            if (model.发票类型名称 != null)
            {
                strSql1.Append("发票类型名称,");
                strSql2.Append("'" + model.发票类型名称 + "',");
            }
            if (model.发票日期 != null)
            {
                strSql1.Append("发票日期,");
                strSql2.Append("'" + model.发票日期 + "',");
            }
            if (model.客户编码 != null)
            {
                strSql1.Append("客户编码,");
                strSql2.Append("'" + model.客户编码 + "',");
            }
            if (model.客户旧编码 != null)
            {
                strSql1.Append("客户旧编码,");
                strSql2.Append("'" + model.客户旧编码 + "',");
            }
            if (model.客户名称 != null)
            {
                strSql1.Append("客户名称,");
                strSql2.Append("'" + model.客户名称 + "',");
            }
            if (model.代理商编码 != null)
            {
                strSql1.Append("代理商编码,");
                strSql2.Append("'" + model.代理商编码 + "',");
            }
            if (model.代理商名称 != null)
            {
                strSql1.Append("代理商名称,");
                strSql2.Append("'" + model.代理商名称 + "',");
            }
            if (model.业务员编码 != null)
            {
                strSql1.Append("业务员编码,");
                strSql2.Append("'" + model.业务员编码 + "',");
            }
            if (model.业务员名称 != null)
            {
                strSql1.Append("业务员名称,");
                strSql2.Append("'" + model.业务员名称 + "',");
            }
            if (model.省份编码 != null)
            {
                strSql1.Append("省份编码,");
                strSql2.Append("'" + model.省份编码 + "',");
            }
            if (model.省份名称 != null)
            {
                strSql1.Append("省份名称,");
                strSql2.Append("'" + model.省份名称 + "',");
            }
            if (model.城市编码 != null)
            {
                strSql1.Append("城市编码,");
                strSql2.Append("'" + model.城市编码 + "',");
            }
            if (model.发货单号 != null)
            {
                strSql1.Append("发货单号,");
                strSql2.Append("'" + model.发货单号 + "',");
            }
            if (model.发货行号 != null)
            {
                strSql1.Append("发货行号,");
                strSql2.Append("" + model.发货行号 + ",");
            }
            if (model.货物编码 != null)
            {
                strSql1.Append("货物编码,");
                strSql2.Append("'" + model.货物编码 + "',");
            }
            if (model.货物旧编码 != null)
            {
                strSql1.Append("货物旧编码,");
                strSql2.Append("'" + model.货物旧编码 + "',");
            }
            if (model.货物名称 != null)
            {
                strSql1.Append("货物名称,");
                strSql2.Append("'" + model.货物名称 + "',");
            }
            if (model.规格型号 != null)
            {
                strSql1.Append("规格型号,");
                strSql2.Append("'" + model.规格型号 + "',");
            }
            if (model.批次 != null)
            {
                strSql1.Append("批次,");
                strSql2.Append("'" + model.批次 + "',");
            }
            if (model.单价 != null)
            {
                strSql1.Append("单价,");
                strSql2.Append("" + model.单价 + ",");
            }
            if (model.开票数量 != null)
            {
                strSql1.Append("开票数量,");
                strSql2.Append("" + model.开票数量 + ",");
            }
            if (model.金额 != null)
            {
                strSql1.Append("金额,");
                strSql2.Append("" + model.金额 + ",");
            }
            if (model.货币单位 != null)
            {
                strSql1.Append("货币单位,");
                strSql2.Append("'" + model.货币单位 + "',");
            }
            if (model.金税发票号码 != null)
            {
                strSql1.Append("金税发票号码,");
                strSql2.Append("'" + model.金税发票号码 + "',");
            }
            if (model.发票已取消 != null)
            {
                strSql1.Append("发票已取消,");
                strSql2.Append("'" + model.发票已取消 + "',");
            }
            if (model.被冲销的号码 != null)
            {
                strSql1.Append("被冲销的号码,");
                strSql2.Append("'" + model.被冲销的号码 + "',");
            }
            if (model.PO项目 != null)
            {
                strSql1.Append("PO项目,");
                strSql2.Append("'" + model.PO项目 + "',");
            }
            if (model.导入人 != null)
            {
                strSql1.Append("导入人,");
                strSql2.Append("'" + model.导入人 + "',");
            }
            strSql1.Append("导入人,");
            strSql2.Append("getdate(),");
            strSql.Append("insert into _发票_sap(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            return(strSql.ToString());
        }
Exemple #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public string Update(UFIDA.U8.UAP.CustomApp.ControlForm.Model._发票_sap model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update _发票_sap set ");
            if (model.销售组织 != null)
            {
                strSql.Append("销售组织='" + model.销售组织 + "',");
            }
            else
            {
                strSql.Append("销售组织= null ,");
            }
            if (model.发票号码 != null)
            {
                strSql.Append("发票号码='" + model.发票号码 + "',");
            }
            else
            {
                strSql.Append("发票号码= null ,");
            }
            if (model.发票类型 != null)
            {
                strSql.Append("发票类型='" + model.发票类型 + "',");
            }
            else
            {
                strSql.Append("发票类型= null ,");
            }
            if (model.发票类型名称 != null)
            {
                strSql.Append("发票类型名称='" + model.发票类型名称 + "',");
            }
            else
            {
                strSql.Append("发票类型名称= null ,");
            }
            if (model.发票日期 != null)
            {
                strSql.Append("发票日期='" + model.发票日期 + "',");
            }
            else
            {
                strSql.Append("发票日期= null ,");
            }
            if (model.客户编码 != null)
            {
                strSql.Append("客户编码='" + model.客户编码 + "',");
            }
            else
            {
                strSql.Append("客户编码= null ,");
            }
            if (model.客户名称 != null)
            {
                strSql.Append("客户名称='" + model.客户名称 + "',");
            }
            else
            {
                strSql.Append("客户名称= null ,");
            }
            if (model.代码商编码 != null)
            {
                strSql.Append("代码商编码='" + model.代码商编码 + "',");
            }
            else
            {
                strSql.Append("代码商编码= null ,");
            }
            if (model.代理商名称 != null)
            {
                strSql.Append("代理商名称='" + model.代理商名称 + "',");
            }
            else
            {
                strSql.Append("代理商名称= null ,");
            }
            if (model.业务员编码 != null)
            {
                strSql.Append("业务员编码='" + model.业务员编码 + "',");
            }
            else
            {
                strSql.Append("业务员编码= null ,");
            }
            if (model.业务员名称 != null)
            {
                strSql.Append("业务员名称='" + model.业务员名称 + "',");
            }
            else
            {
                strSql.Append("业务员名称= null ,");
            }
            if (model.省份编码 != null)
            {
                strSql.Append("省份编码='" + model.省份编码 + "',");
            }
            else
            {
                strSql.Append("省份编码= null ,");
            }
            if (model.省份名称 != null)
            {
                strSql.Append("省份名称='" + model.省份名称 + "',");
            }
            else
            {
                strSql.Append("省份名称= null ,");
            }
            if (model.城市编码 != null)
            {
                strSql.Append("城市编码='" + model.城市编码 + "',");
            }
            else
            {
                strSql.Append("城市编码= null ,");
            }
            if (model.发货单号 != null)
            {
                strSql.Append("发货单号='" + model.发货单号 + "',");
            }
            else
            {
                strSql.Append("发货单号= null ,");
            }
            if (model.发货行号 != null)
            {
                strSql.Append("发货行号=" + model.发货行号 + ",");
            }
            else
            {
                strSql.Append("发货行号= null ,");
            }
            if (model.货物编码 != null)
            {
                strSql.Append("货物编码='" + model.货物编码 + "',");
            }
            else
            {
                strSql.Append("货物编码= null ,");
            }
            if (model.货物名称 != null)
            {
                strSql.Append("货物名称='" + model.货物名称 + "',");
            }
            else
            {
                strSql.Append("货物名称= null ,");
            }
            if (model.规格型号 != null)
            {
                strSql.Append("规格型号='" + model.规格型号 + "',");
            }
            else
            {
                strSql.Append("规格型号= null ,");
            }
            if (model.批次 != null)
            {
                strSql.Append("批次='" + model.批次 + "',");
            }
            else
            {
                strSql.Append("批次= null ,");
            }
            if (model.单价 != null)
            {
                strSql.Append("单价=" + model.单价 + ",");
            }
            else
            {
                strSql.Append("单价= null ,");
            }
            if (model.开票数量 != null)
            {
                strSql.Append("开票数量=" + model.开票数量 + ",");
            }
            else
            {
                strSql.Append("开票数量= null ,");
            }
            if (model.金额 != null)
            {
                strSql.Append("金额=" + model.金额 + ",");
            }
            else
            {
                strSql.Append("金额= null ,");
            }
            if (model.货币单位 != null)
            {
                strSql.Append("货币单位='" + model.货币单位 + "',");
            }
            else
            {
                strSql.Append("货币单位= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where iID=" + model.iID + "");
            return(strSql.ToString());
        }
Exemple #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    gridView1.FocusedRowHandle -= 1;
                    gridView1.FocusedRowHandle += 1;
                }
                catch { }

                SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    int    iCou = 0;
                    string sErr = "";
                    string sSQL = "";

                    string sString = "";

                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        bool b = BaseFunction.ReturnBool(gridView1.GetRowCellValue(i, gridCol选择));
                        if (!b)
                        {
                            continue;
                        }

                        sSQL = @"
select count(1) as iCou from [dbo].[_高开返利单_SZ] where cSBVCode = '{0}'
                        ";
                        sSQL = string.Format(sSQL, gridView1.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
                        long l = BaseFunction.ReturnLong(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
                        if (l > 0)
                        {
                            sString = sString + "行 " + (i + 1).ToString() + "已经做了高开返利单\n";
                            gridView1.SetRowCellValue(i, gridCol选择, false);
                            continue;
                        }

                        //未做高开返利单的当月发票全部删除
                        sSQL = @"
delete 
from [dbo].[_发票_sap] 
where year([发票日期]) = {0} and month([发票日期]) = {1}
	and 发票号码 not in (
			select DISTINCT 发票号码 from [_发票_sap] where year([发票日期]) = {0} and month([发票日期]) = {1} and iID in (select FPIDs from [dbo].[_高开返利单_SZ])
			)
";
                        sSQL = string.Format(sSQL, BaseFunction.ReturnInt(lookUpEditYear.EditValue).ToString().Trim(), BaseFunction.ReturnInt(lookUpEditMonth.EditValue).ToString().Trim());
                        DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

//                        sSQL = @"
//select count(1) as iCou from [_发票_sap] where 发票号码 = '{0}'
//                        ";
//                        sSQL = string.Format(sSQL, gridView1.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
//                        l = BaseFunction.ReturnLong(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);

//                        if (l > 0)
//                        {
//                            sSQL = @"
//delete  [_发票_sap] where 发票号码 = '{0}'
//                        ";
//                            sSQL = string.Format(sSQL, gridView1.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
//                            DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
//                        }
                    }

                    if (sString.Length > 0)
                    {
                        FrmMsgBox frm = new FrmMsgBox();
                        frm.Text = "存在已经做了高开返利单,是否继续?";
                        frm.richTextBox1.Text = sString;

                        frm.ShowDialog();


                        if (DialogResult.OK != frm.DialogResult)
                        {
                            throw new Exception("用户取消操作!");
                        }
                    }

                    try
                    {
                        gridView1.FocusedRowHandle -= 1;
                        gridView1.FocusedRowHandle += 1;
                    }
                    catch { }


                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        bool b = BaseFunction.ReturnBool(gridView1.GetRowCellValue(i, gridCol选择));
                        if (!b)
                        {
                            continue;
                        }

//                        sSQL = @"
//select count(1) as iCou from [dbo].[_高开返利单_SZ] where cSBVCode = '{0}'
//                        ";
//                        sSQL = string.Format(sSQL, gridView1.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
//                        long l = BaseFunction.ReturnLong(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
//                        if (l > 0)
//                        {
//                            sString = sString + "行 " + (i + 1).ToString() + "已经做了高开返利单";
//                            continue;
//                        }


//                        sSQL = @"
//select count(1) as iCou from [_发票_sap] where 发票号码 = '{0}'
//                        ";
//                        sSQL = string.Format(sSQL, gridView1.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
//                        l = BaseFunction.ReturnLong(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);

//                        if (l > 0)
//                        {
//                            sSQL = @"
//delete  [_发票_sap] where 发票号码 = '{0}'
//                        ";
//                            sSQL = string.Format(sSQL, gridView1.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
//                            DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
//                        }

                        Model._发票_sap mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._发票_sap();
                        mod.销售组织   = gridView1.GetRowCellDisplayText(i, gridCol销售组织).ToString().Trim();
                        mod.发票号码   = gridView1.GetRowCellDisplayText(i, gridCol发票号码).ToString().Trim();
                        mod.发票类型   = gridView1.GetRowCellDisplayText(i, gridCol发票类型).ToString().Trim();
                        mod.发票类型名称 = gridView1.GetRowCellDisplayText(i, gridCol发票类型名称).ToString().Trim();
                        mod.发票日期   = BaseFunction.ReturnDate(gridView1.GetRowCellDisplayText(i, gridCol发票日期).ToString().Trim());
                        mod.客户编码   = gridView1.GetRowCellDisplayText(i, gridCol客户编码).ToString().Trim();
                        mod.客户名称   = gridView1.GetRowCellDisplayText(i, gridCol客户名称).ToString().Trim();
                        mod.代理商编码  = gridView1.GetRowCellDisplayText(i, gridCol代理商编码).ToString().Trim();
                        mod.代理商名称  = gridView1.GetRowCellDisplayText(i, gridCol代理商名称).ToString().Trim();
                        mod.业务员编码  = gridView1.GetRowCellDisplayText(i, gridCol业务员编码).ToString().Trim();
                        mod.业务员名称  = gridView1.GetRowCellDisplayText(i, gridCol业务员名称).ToString().Trim();
                        mod.省份编码   = gridView1.GetRowCellDisplayText(i, gridCol省份编码).ToString().Trim();
                        mod.省份名称   = gridView1.GetRowCellDisplayText(i, gridCol省份名称).ToString().Trim();
                        mod.城市编码   = gridView1.GetRowCellDisplayText(i, gridCol城市编码).ToString().Trim();
                        mod.发货单号   = gridView1.GetRowCellDisplayText(i, gridCol发货单号).ToString().Trim();
                        mod.发货行号   = BaseFunction.ReturnInt(gridView1.GetRowCellDisplayText(i, gridCol发货行号).ToString().Trim());
                        mod.货物编码   = gridView1.GetRowCellDisplayText(i, gridCol货物编码).ToString().Trim();
                        mod.货物旧编码  = gridView1.GetRowCellDisplayText(i, gridCol货物旧编码).ToString().Trim();
                        mod.货物名称   = gridView1.GetRowCellDisplayText(i, gridCol货物名称).ToString().Trim();
                        mod.规格型号   = gridView1.GetRowCellDisplayText(i, gridCol规格型号).ToString().Trim();
                        mod.批次     = gridView1.GetRowCellDisplayText(i, gridCol批次).ToString().Trim();
                        mod.单价     = BaseFunction.ReturnDecimal(gridView1.GetRowCellDisplayText(i, gridCol单价).ToString().Trim());
                        mod.开票数量   = BaseFunction.ReturnDecimal(gridView1.GetRowCellDisplayText(i, gridCol开票数量).ToString().Trim());
                        mod.金额     = BaseFunction.ReturnDecimal(gridView1.GetRowCellDisplayText(i, gridCol金额).ToString().Trim());
                        mod.货币单位   = gridView1.GetRowCellDisplayText(i, gridCol货币单位).ToString().Trim();
                        mod.发票已取消  = gridView1.GetRowCellDisplayText(i, gridCol发票已取消).ToString().Trim();
                        mod.被冲销的号码 = gridView1.GetRowCellDisplayText(i, gridCol被冲销的号码).ToString().Trim();
                        mod.PO项目   = gridView1.GetRowCellDisplayText(i, gridColPO项目).ToString().Trim();
                        mod.iID    = BaseFunction.ReturnLong(gridView1.GetRowCellDisplayText(i, gridColiID));
                        mod.金税发票号码 = gridView1.GetRowCellDisplayText(i, gridCol金税发票号码).ToString().Trim();

                        DAL._发票_sap dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._发票_sap();


                        if (b编辑 && mod.iID > 0)
                        {
                            sSQL = dal.Update(mod);
                        }
                        else
                        {
                            sSQL = dal.Add(mod);
                        }
                        iCou = iCou + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    }

                    if (sErr.Length > 0)
                    {
                        throw new Exception(sErr.Trim());
                    }

                    b编辑 = false;

                    if (iCou > 0)
                    {
                        tran.Commit();

                        MessageBox.Show("导入发票成功");

                        gridControl1.DataSource = null;
                    }
                    else
                    {
                        throw new Exception("请选择需要保存的数据");
                    }
                }

                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
            catch (Exception ee)
            {
                FrmMsgBox f = new FrmMsgBox();
                f.Text = "保存失败";
                f.richTextBox1.Text = ee.Message;
                f.ShowDialog();
            }
        }
Exemple #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    gridView回款.FocusedRowHandle -= 1;
                    gridView回款.FocusedRowHandle += 1;

                    gridView发票.FocusedRowHandle -= 1;
                    gridView发票.FocusedRowHandle += 1;
                }
                catch { }


                if (radio发票.Checked)
                {
                    SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString);
                    conn.Open();
                    //启用事务
                    SqlTransaction tran = conn.BeginTransaction();
                    try
                    {
                        int    iCou = 0;
                        string sErr = "";
                        string sSQL = "";

                        for (int i = 0; i < gridView发票.RowCount; i++)
                        {
                            sSQL = @"
select count(1) as iCou from [dbo].[_高开返利单] where cSBVCode = '{0}'
";
                            sSQL = string.Format(sSQL, gridView发票.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
                            long l = BaseFunction.ReturnLong(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
                            if (l > 0)
                            {
                                sErr = sErr + "行 " + (i + 1).ToString() + "已经做了高开返利单";
                                continue;
                            }

                            sSQL = @"
select count(1) as iCou from [_发票_sap] where 发票号码 = '{0}'
";
                            sSQL = string.Format(sSQL, gridView发票.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
                            l    = BaseFunction.ReturnLong(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);

                            if (l > 0)
                            {
                                sSQL = @"
delete  [_发票_sap] where 发票号码 = '{0}'
";
                                sSQL = string.Format(sSQL, gridView发票.GetRowCellValue(i, gridCol发票号码).ToString().Trim());
                                DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                            }
                        }

                        for (int i = 0; i < gridView发票.RowCount; i++)
                        {
                            Model._发票_sap mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._发票_sap();
                            mod.销售组织   = gridView发票.GetRowCellValue(i, gridCol销售组织).ToString().Trim();
                            mod.发票号码   = gridView发票.GetRowCellValue(i, gridCol发票号码).ToString().Trim();
                            mod.发票类型   = gridView发票.GetRowCellValue(i, gridCol发票类型).ToString().Trim();
                            mod.发票类型名称 = gridView发票.GetRowCellValue(i, gridCol发票类型名称).ToString().Trim();
                            mod.发票日期   = BaseFunction.ReturnDate(gridView发票.GetRowCellValue(i, gridCol发票日期).ToString().Trim());
                            mod.客户编码   = gridView发票.GetRowCellValue(i, gridCol客户编码).ToString().Trim();
                            mod.客户名称   = gridView发票.GetRowCellValue(i, gridCol客户名称).ToString().Trim();
                            mod.代码商编码  = gridView发票.GetRowCellValue(i, gridCol代码商编码).ToString().Trim();
                            mod.代理商名称  = gridView发票.GetRowCellValue(i, gridCol代理商名称).ToString().Trim();
                            mod.业务员编码  = gridView发票.GetRowCellValue(i, gridCol业务员编码).ToString().Trim();
                            mod.业务员名称  = gridView发票.GetRowCellValue(i, gridCol业务员名称).ToString().Trim();
                            mod.省份编码   = gridView发票.GetRowCellValue(i, gridCol省份编码).ToString().Trim();
                            mod.省份名称   = gridView发票.GetRowCellValue(i, gridCol省份名称).ToString().Trim();
                            mod.城市编码   = gridView发票.GetRowCellValue(i, gridCol城市编码).ToString().Trim();
                            mod.发货单号   = gridView发票.GetRowCellValue(i, gridCol发货单号).ToString().Trim();
                            mod.发货行号   = BaseFunction.ReturnInt(gridView发票.GetRowCellValue(i, gridCol发货行号).ToString().Trim());
                            mod.货物编码   = gridView发票.GetRowCellValue(i, gridCol货物编码).ToString().Trim();
                            mod.货物名称   = gridView发票.GetRowCellValue(i, gridCol货物名称).ToString().Trim();
                            mod.规格型号   = gridView发票.GetRowCellValue(i, gridCol规格型号).ToString().Trim();
                            mod.批次     = gridView发票.GetRowCellValue(i, gridCol批次).ToString().Trim();
                            mod.单价     = BaseFunction.ReturnDecimal(gridView发票.GetRowCellValue(i, gridCol单价).ToString().Trim());
                            mod.开票数量   = BaseFunction.ReturnDecimal(gridView发票.GetRowCellValue(i, gridCol开票数量).ToString().Trim());
                            mod.金额     = BaseFunction.ReturnDecimal(gridView发票.GetRowCellValue(i, gridCol金额).ToString().Trim());
                            mod.货币单位   = gridView发票.GetRowCellValue(i, gridCol货币单位).ToString().Trim();

                            DAL._发票_sap dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._发票_sap();
                            sSQL = dal.Add(mod);
                            iCou = iCou + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        }

                        if (sErr.Length > 0)
                        {
                            throw new Exception(sErr.Trim());
                        }

                        if (iCou > 0)
                        {
                            tran.Commit();

                            MessageBox.Show("导入发票成功");

                            gridControl发票.DataSource = null;
                        }
                        else
                        {
                            throw new Exception("请选择需要保存的数据");
                        }
                    }

                    catch (Exception error)
                    {
                        tran.Rollback();
                        throw new Exception(error.Message);
                    }
                }
            }
            catch (Exception ee)
            {
                FrmMsgBox f = new FrmMsgBox();
                f.Text = "保存失败";
                f.richTextBox1.Text = ee.Message;
                f.ShowDialog();
            }

            if (radio回款.Checked)
            {
                SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    int    iCou = 0;
                    string sErr = "";

                    string sSQL = "";
                    for (int i = 0; i < gridView回款.RowCount; i++)
                    {
                        sSQL = @"
select count(1) as iCou from [_回款_sap] where [收款单号] = '{0}'
";
                        sSQL = string.Format(sSQL, gridView回款.GetRowCellValue(i, gridCol_收款单号).ToString().Trim());
                        long l = BaseFunction.ReturnLong(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);

                        if (l > 0)
                        {
                            sSQL = @"
delete  [_回款_sap] where 收款单号 = '{0}'
";
                            sSQL = string.Format(sSQL, gridView回款.GetRowCellValue(i, gridCol_收款单号).ToString().Trim());
                            DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        }
                    }
                    for (int i = 0; i < gridView回款.RowCount; i++)
                    {
                        Model._回款_sap mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._回款_sap();

                        mod.收款单号  = gridView回款.GetRowCellValue(i, gridCol_收款单号).ToString().Trim();
                        mod.收款单日期 = BaseFunction.ReturnDate(gridView回款.GetRowCellValue(i, gridCol_收款单日期).ToString().Trim());
                        mod.收款单金额 = BaseFunction.ReturnDecimal(gridView回款.GetRowCellValue(i, gridCol_收款单金额).ToString().Trim());
                        mod.业务员编码 = gridView回款.GetRowCellValue(i, gridCol_业务员编码).ToString().Trim();
                        mod.业务员   = gridView回款.GetRowCellValue(i, gridCol_业务员).ToString().Trim();
                        mod.核销金额  = BaseFunction.ReturnDecimal(gridView回款.GetRowCellValue(i, gridCol_核销金额).ToString().Trim());
                        mod.核销日期  = BaseFunction.ReturnDate(gridView回款.GetRowCellValue(i, gridCol_核销日期).ToString().Trim());
                        mod.发票号码  = gridView回款.GetRowCellValue(i, gridCol_发票号码).ToString().Trim();
                        mod.发票日期  = BaseFunction.ReturnDate(gridView回款.GetRowCellValue(i, gridCol_发票日期).ToString().Trim());
                        mod.销售组织  = gridView回款.GetRowCellValue(i, gridCol_销售组织).ToString().Trim();
                        mod.客户编码  = gridView回款.GetRowCellValue(i, gridCol_客户编码).ToString().Trim();
                        mod.客户名称  = gridView回款.GetRowCellValue(i, gridCol客户名称).ToString().Trim();
                        mod.发票金额  = BaseFunction.ReturnDecimal(gridView回款.GetRowCellValue(i, gridCol_发票金额).ToString().Trim());
                        mod.货币单位  = gridView回款.GetRowCellValue(i, gridCol_货币单位).ToString().Trim();

                        DAL._回款_sap dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._回款_sap();
                        sSQL = dal.Add(mod);

                        iCou = iCou + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                    }

                    if (sErr.Length > 0)
                    {
                        throw new Exception(sErr.Trim());
                    }

                    if (iCou > 0)
                    {
                        tran.Commit();

                        MessageBox.Show("导入回款成功");

                        gridControl回款.DataSource = null;
                    }
                    else
                    {
                        throw new Exception("请选择需要保存的数据");
                    }
                }

                catch (Exception error)
                {
                    tran.Rollback();
                    throw new Exception(error.Message);
                }
            }
        }