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

            strSql.Append("update _Process set ");
            if (model.Process != null)
            {
                strSql.Append("Process='" + model.Process + "',");
            }
            else
            {
                strSql.Append("Process= null ,");
            }
            if (model.Condition != null)
            {
                strSql.Append("Condition='" + model.Condition + "',");
            }
            else
            {
                strSql.Append("Condition= null ,");
            }
            if (model.PLATINGSPEC != null)
            {
                strSql.Append("PLATINGSPEC='" + model.PLATINGSPEC + "',");
            }
            else
            {
                strSql.Append("PLATINGSPEC= null ,");
            }
            if (model.THICKNESS != null)
            {
                strSql.Append("THICKNESS='" + model.THICKNESS + "',");
            }
            else
            {
                strSql.Append("THICKNESS= null ,");
            }
            if (model.TIME != null)
            {
                strSql.Append("TIME=" + model.TIME + ",");
            }
            else
            {
                strSql.Append("TIME= null ,");
            }
            if (model.AMPHRS != null)
            {
                strSql.Append("AMPHRS='" + model.AMPHRS + "',");
            }
            else
            {
                strSql.Append("AMPHRS= null ,");
            }
            if (model.cWhCode != null)
            {
                strSql.Append("cWhCode='" + model.cWhCode + "',");
            }
            else
            {
                strSql.Append("cWhCode= null ,");
            }
            if (model.Price != null)
            {
                strSql.Append("Price=" + model.Price + ",");
            }
            else
            {
                strSql.Append("Price= null ,");
            }
            if (model.Remark != null)
            {
                strSql.Append("Remark='" + model.Remark + "',");
            }
            else
            {
                strSql.Append("Remark= null ,");
            }
            if (model.CreateUid != null)
            {
                strSql.Append("CreateUid='" + model.CreateUid + "',");
            }
            else
            {
                strSql.Append("CreateUid= null ,");
            }
            if (model.CreateDate != null)
            {
                strSql.Append("CreateDate='" + model.CreateDate + "',");
            }
            else
            {
                strSql.Append("CreateDate= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

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

            if (model.ProcessNo != null)
            {
                strSql1.Append("ProcessNo,");
                strSql2.Append("'" + model.ProcessNo + "',");
            }
            if (model.Process != null)
            {
                strSql1.Append("Process,");
                strSql2.Append("'" + model.Process + "',");
            }
            if (model.Condition != null)
            {
                strSql1.Append("Condition,");
                strSql2.Append("'" + model.Condition + "',");
            }
            if (model.PLATINGSPEC != null)
            {
                strSql1.Append("PLATINGSPEC,");
                strSql2.Append("'" + model.PLATINGSPEC + "',");
            }
            if (model.THICKNESS != null)
            {
                strSql1.Append("THICKNESS,");
                strSql2.Append("'" + model.THICKNESS + "',");
            }
            if (model.TIME != null)
            {
                strSql1.Append("TIME,");
                strSql2.Append("" + model.TIME + ",");
            }
            if (model.AMPHRS != null)
            {
                strSql1.Append("AMPHRS,");
                strSql2.Append("'" + model.AMPHRS + "',");
            }
            if (model.cWhCode != null)
            {
                strSql1.Append("cWhCode,");
                strSql2.Append("'" + model.cWhCode + "',");
            }
            if (model.Price != null)
            {
                strSql1.Append("Price,");
                strSql2.Append("" + model.Price + ",");
            }
            if (model.Remark != null)
            {
                strSql1.Append("Remark,");
                strSql2.Append("'" + model.Remark + "',");
            }
            if (model.CreateUid != null)
            {
                strSql1.Append("CreateUid,");
                strSql2.Append("'" + model.CreateUid + "',");
            }
            if (model.CreateDate != null)
            {
                strSql1.Append("CreateDate,");
                strSql2.Append("'" + model.CreateDate + "',");
            }
            strSql.Append("insert into _Process(");
            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());
        }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string sErr   = "";
            int    iCount = 0;

            try
            {
                try
                {
                    gridView1.FocusedRowHandle -= 1;
                    gridView1.FocusedRowHandle += 1;
                }
                catch { }


                SqlConnection conn = new SqlConnection(Conn);
                conn.Open();
                SqlTransaction tran = conn.BeginTransaction();
                try
                {
                    string   sSQL     = "select getdate()";
                    DateTime dNow     = BaseFunction.ReturnDate(DbHelperSQL.ExecuteDataset(tran, CommandType.Text, sSQL).Tables[0].Rows[0][0]);
                    DateTime dNowDate = BaseFunction.ReturnDate(dNow.ToString("yyyy-MM-dd"));

                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        int    iID    = BaseFunction.ReturnInt(gridView1.GetRowCellValue(i, gridColiID));
                        string iState = gridView1.GetRowCellValue(i, gridColiState).ToString().Trim();

                        if (iState == "")
                        {
                            continue;
                        }

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

                        Model._Process model = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._Process();
                        model.ProcessNo = gridView1.GetRowCellValue(i, gridColProcessNo).ToString().Trim();
                        model.Process   = gridView1.GetRowCellValue(i, gridColProcess).ToString().Trim();
                        if (model.Process == "")
                        {
                            sErr = sErr + "Row " + (i + 1).ToString() + " error\n";
                            continue;
                        }

                        model.Condition   = gridView1.GetRowCellValue(i, gridColCondition).ToString().Trim();
                        model.PLATINGSPEC = gridView1.GetRowCellValue(i, gridColPLATINGSPEC).ToString().Trim();
                        model.TIME        = BaseFunction.ReturnDecimal(gridView1.GetRowCellValue(i, gridColTIME));
                        model.THICKNESS   = gridView1.GetRowCellValue(i, gridColTHICKNESS).ToString().Trim();
                        model.AMPHRS      = gridView1.GetRowCellValue(i, gridColAMPHRS).ToString().Trim();
                        model.Remark      = gridView1.GetRowCellValue(i, gridColRemark).ToString().Trim();

                        if (iID == 0)
                        {
                            model.CreateUid  = sUserID;
                            model.CreateDate = dNowDate;

                            DAL._Process dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._Process();
                            sSQL   = dal.Add(model);
                            iCount = iCount + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        }
                        else
                        {
                            model.CreateUid  = gridView1.GetRowCellValue(i, gridColCreateUid).ToString().Trim();
                            model.CreateDate = BaseFunction.ReturnDate(gridView1.GetRowCellValue(i, gridColCreateDate));
                            DAL._Process dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._Process();
                            sSQL   = dal.Update(model);
                            iCount = iCount + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        }
                    }

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

                    if (iCount > 0)
                    {
                        tran.Commit();

                        MessageBox.Show("OK");

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