Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(UFIDA.U8.UAP.CustomApp.ControlForm.Model._DSSaleBaseInfo model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.cSTCode != null)
            {
                strSql1.Append("cSTCode,");
                strSql2.Append("'" + model.cSTCode + "',");
            }
            if (model.bDS != null)
            {
                strSql1.Append("bDS,");
                strSql2.Append("" + (model.bDS ? 1 : 0) + ",");
            }

            strSql.Append("insert into _DSSaleBaseInfo(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            return(strSql.ToString());
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public string Update(UFIDA.U8.UAP.CustomApp.ControlForm.Model._DSSaleBaseInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update _DSSaleBaseInfo set ");
            if (model.bDS != null)
            {
                strSql.Append("bDS=" + (model.bDS ? 1 : 0) + ",");
            }
            else
            {
                strSql.Append("bDS= null ,");
            }

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

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

                string sErr = "";

                SqlConnection conn = new SqlConnection(Conn);
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();

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

                        if (gridView1.GetRowCellValue(i, gridColcSTCode).ToString().Trim() == "")
                        {
                            continue;
                        }

                        Model._DSSaleBaseInfo mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._DSSaleBaseInfo();
                        mod.cSTCode = gridView1.GetRowCellValue(i, gridColcSTCode).ToString().Trim();
                        mod.bDS     = BaseFunction.ReturnBool(gridView1.GetRowCellValue(i, gridColbCreateDP));

                        DAL._DSSaleBaseInfo dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._DSSaleBaseInfo();
                        string sSQL             = dal.Exists(mod.cSTCode);
                        int    iDataCou         = BaseFunction.ReturnInt(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
                        if (iDataCou > 0)
                        {
                            sSQL = dal.Update(mod);
                            iCou = iCou + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        }
                        else
                        {
                            sSQL = dal.Add(mod);
                            iCou = iCou + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        }
                    }

                    if (sErr != "")
                    {
                        throw new Exception(sErr);
                    }

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

                    MessageBox.Show("Save sucess");

                    btnQuery_Click(null, null);
                    //}
                }
                catch (Exception ee)
                {
                    tran.Rollback();
                    throw new Exception(ee.Message);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("Save err:" + ee.Message);
            }
        }