Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public string Update(UFIDA.U8.UAP.CustomApp.ControlForm.Model.fitemss00 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update fitemss00 set ");

            if (model.citemname != null)
            {
                strSql.Append("citemname='" + model.citemname + "',");
            }
            else
            {
                strSql.Append("citemname= null ,");
            }
            if (model.金额 != null)
            {
                strSql.Append("金额=" + model.金额 + ",");
            }
            else
            {
                strSql.Append("金额= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where citemcode='" + model.citemcode + "' and citemccode = '" + model.citemccode + "'");
            return(strSql.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(UFIDA.U8.UAP.CustomApp.ControlForm.Model.fitemss00 model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.citemcode != null)
            {
                strSql1.Append("citemcode,");
                strSql2.Append("'" + model.citemcode + "',");
            }
            if (model.citemname != null)
            {
                strSql1.Append("citemname,");
                strSql2.Append("'" + model.citemname + "',");
            }
            if (model.bclose != null)
            {
                strSql1.Append("bclose,");
                strSql2.Append("" + (model.bclose ? 1 : 0) + ",");
            }
            if (model.citemccode != null)
            {
                strSql1.Append("citemccode,");
                strSql2.Append("'" + model.citemccode + "',");
            }
            if (model.iotherused != null)
            {
                strSql1.Append("iotherused,");
                strSql2.Append("" + model.iotherused + ",");
            }
            if (model.金额 != null)
            {
                strSql1.Append("金额,");
                strSql2.Append("" + model.金额 + ",");
            }
            strSql.Append("insert into fitemss00(");
            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());
        }
Exemplo n.º 3
0
        private void btnAudit_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    gridView1.FocusedRowHandle -= 1;
                    gridView1.FocusedRowHandle += 1;
                }
                catch { }

                string        sErr = "";
                int           iCou = 0;
                SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString);
                conn.Open();
                //启用事务
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    if (txt单据号.Text.Trim() == "")
                    {
                        throw new Exception("请选择单据");
                    }

                    string sSQL = @"
select * from [dbo].[_高开返利单_SZ] where cCode = '{0}' 
";
                    sSQL = string.Format(sSQL, txt单据号.Text.Trim());
                    DataTable dt = DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0];
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        throw new Exception("单据不存在");
                    }

                    if (dt.Rows[0]["auditUid"].ToString().Trim() != "")
                    {
                        throw new Exception("单据已经审核");
                    }

                    sSQL = @"
update [dbo].[_高开返利单_SZ] set [auditUid] = '{0}',[dtmAudit] = getdate()
where [cCode] = '{1}'
";
                    sSQL = string.Format(sSQL, sUserID, txt单据号.Text.Trim());
                    iCou = DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);


                    sSQL = @"
select cCode,sum(iMoneyFL) as  iMoneyFL,sum(isum) as iSum
from [dbo].[_高开返利单_SZ]
where cCode = '{0}'
group by cCode 
";
                    sSQL = string.Format(sSQL, txt单据号.Text.Trim());
                    decimal d金额 = BaseFunction.ReturnDecimal(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0]["iMoneyFL"]);

                    Model.fitemss00 modFitem = new UFIDA.U8.UAP.CustomApp.ControlForm.Model.fitemss00();

                    if (gridView1.GetRowCellDisplayText(0, gridCol是否直营).ToString().Trim() != "直营")
                    {
                        modFitem.citemccode = "02";
                    }
                    else
                    {
                        modFitem.citemccode = "01";
                    }
                    modFitem.citemcode = txt单据号.Text.Trim();
                    modFitem.citemname = gridView1.GetRowCellValue(0, gridCol代理商).ToString().Trim();
                    modFitem.bclose    = false;
                    modFitem.金额        = d金额;

                    DAL.fitemss00 dalFitem = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL.fitemss00();
                    sSQL = dalFitem.Exists(modFitem.citemcode);
                    int iCount = BaseFunction.ReturnInt(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
                    if (iCount > 0)
                    {
                        sSQL = dalFitem.Update(modFitem);
                    }
                    else
                    {
                        sSQL = dalFitem.Add(modFitem);
                    }
                    DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);

                    tran.Commit();

                    if (iCou > 0)
                    {
                        MessageBox.Show("审核成功");
                        SetEnable(false);
                    }
                }
                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();
            }
        }