コード例 #1
0
ファイル: _AQLSampleSizeMap.cs プロジェクト: chrgu000/DEMO
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public string Add(UFIDA.U8.UAP.CustomApp.ControlForm.Model._AQLSampleSizeMap model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.CodeLetter != null)
            {
                strSql1.Append("CodeLetter,");
                strSql2.Append("'" + model.CodeLetter + "',");
            }
            if (model.SampleSize != null)
            {
                strSql1.Append("SampleSize,");
                strSql2.Append("" + model.SampleSize + ",");
            }
            strSql.Append("insert into _AQLSampleSizeMap(");
            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());
        }
コード例 #2
0
ファイル: _AQLSampleSizeMap.cs プロジェクト: chrgu000/DEMO
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public string Update(UFIDA.U8.UAP.CustomApp.ControlForm.Model._AQLSampleSizeMap model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update _AQLSampleSizeMap set ");
            if (model.SampleSize != null)
            {
                strSql.Append("SampleSize=" + model.SampleSize + ",");
            }
            else
            {
                strSql.Append("SampleSize= null ,");
            }
            if (model.CodeLetter != null)
            {
                strSql.Append("CodeLetter='" + model.CodeLetter + "',");
            }
            else
            {
                strSql.Append("CodeLetter= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

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

            try
            {
                int           iCou = 0;
                SqlConnection conn = new SqlConnection(Conn);
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        string sStatus = gridView1.GetRowCellValue(i, gridColsStatus).ToString().Trim().ToLower();
                        if (sStatus == "")
                        {
                            continue;
                        }

                        Model._AQLSampleSizeMap mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._AQLSampleSizeMap();
                        mod.CodeLetter = gridView1.GetRowCellValue(i, gridColCodeLetter).ToString().Trim();
                        mod.SampleSize = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColSampleSize).ToString().Trim());

                        mod.iID = BaseFunction.ReturnLong(gridView1.GetRowCellValue(i, gridColiID));

                        string sSQL = "";
                        if (sStatus == "add")
                        {
                            DAL._AQLSampleSizeMap dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._AQLSampleSizeMap();
                            sSQL  = dal.Add(mod);
                            iCou += DbHelperSQL.ExecuteSql(sSQL);
                        }
                        if (sStatus == "edit")
                        {
                            DAL._AQLSampleSizeMap dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._AQLSampleSizeMap();
                            sSQL  = dal.Update(mod);
                            iCou += DbHelperSQL.ExecuteSql(sSQL);
                        }
                    }
                    if (iCou > 0)
                    {
                        tran.Commit();

                        MessageBox.Show("OK");
                    }

                    GetGrid();
                    SetBtnEnable(true);
                }
                catch (Exception ee)
                {
                    tran.Rollback();
                    throw new Exception(ee.Message);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }