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

            strSql.Append("update _AQLInspectionLevel set ");
            if (model.minQty != null)
            {
                strSql.Append("minQty=" + model.minQty + ",");
            }
            else
            {
                strSql.Append("minQty= null ,");
            }
            if (model.maxQty != null)
            {
                strSql.Append("maxQty=" + model.maxQty + ",");
            }
            else
            {
                strSql.Append("maxQty= null ,");
            }
            if (model.Level1 != null)
            {
                strSql.Append("Level1='" + model.Level1 + "',");
            }
            else
            {
                strSql.Append("Level1= null ,");
            }
            if (model.Level2 != null)
            {
                strSql.Append("Level2='" + model.Level2 + "',");
            }
            else
            {
                strSql.Append("Level2= null ,");
            }
            if (model.Level3 != null)
            {
                strSql.Append("Level3='" + model.Level3 + "',");
            }
            else
            {
                strSql.Append("Level3= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

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

            if (model.minQty != null)
            {
                strSql1.Append("minQty,");
                strSql2.Append("" + model.minQty + ",");
            }
            if (model.maxQty != null)
            {
                strSql1.Append("maxQty,");
                strSql2.Append("" + model.maxQty + ",");
            }
            if (model.Level1 != null)
            {
                strSql1.Append("Level1,");
                strSql2.Append("'" + model.Level1 + "',");
            }
            if (model.Level2 != null)
            {
                strSql1.Append("Level2,");
                strSql2.Append("'" + model.Level2 + "',");
            }
            if (model.Level3 != null)
            {
                strSql1.Append("Level3,");
                strSql2.Append("'" + model.Level3 + "',");
            }
            strSql.Append("insert into _AQLInspectionLevel(");
            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());
        }
Esempio n. 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._AQLInspectionLevel mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._AQLInspectionLevel();
                        mod.minQty = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColminQty).ToString().Trim());
                        mod.maxQty = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColmaxQty).ToString().Trim());
                        mod.Level1 = gridView1.GetRowCellValue(i, gridColLevel1).ToString().Trim();
                        mod.Level2 = gridView1.GetRowCellValue(i, gridColLevel2).ToString().Trim();
                        mod.Level3 = gridView1.GetRowCellValue(i, gridColLevel3).ToString().Trim();

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

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

                        MessageBox.Show("OK");
                    }

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