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

            strSql.Append("update _DefectMaster_2 set ");
            if (model.DefectName != null)
            {
                strSql.Append("DefectName='" + model.DefectName + "',");
            }
            int n = strSql.ToString().LastIndexOf(",");

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

            if (model.DefectCode != null)
            {
                strSql1.Append("DefectCode,");
                strSql2.Append("'" + model.DefectCode + "',");
            }
            if (model.DefectName != null)
            {
                strSql1.Append("DefectName,");
                strSql2.Append("'" + model.DefectName + "',");
            }
            strSql.Append("insert into _DefectMaster_2(");
            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());
        }
Example #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;
                        }

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

                        Model._DefectMaster_2 mod = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._DefectMaster_2();
                        mod.DefectCode = gridView1.GetRowCellValue(i, gridColDefectCode).ToString().Trim();
                        mod.DefectName = gridView1.GetRowCellValue(i, gridColDefectName).ToString().Trim();
                        mod.DefectID   = BaseFunction.ReturnLong(gridView1.GetRowCellValue(i, gridColDefectID));

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

                        MessageBox.Show("OK");

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