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

            strSql.Append("update _SalesSet set ");
            //if (model.iID != null)
            //{
            //    strSql.Append("iID=" + model.iID + ",");
            //}
            //else
            //{
            //    strSql.Append("iID= null ,");
            //}
            if (model.Creater != null)
            {
                strSql.Append("Creater='" + model.Creater + "',");
            }
            else
            {
                strSql.Append("Creater= null ,");
            }
            if (model.CreateDate != null)
            {
                strSql.Append("CreateDate='" + model.CreateDate + "',");
            }
            else
            {
                strSql.Append("CreateDate= null ,");
            }
            if (model.SalesType != null)
            {
                strSql.Append("SalesType='" + model.SalesType + "',");
            }
            else
            {
                strSql.Append("SalesType= null ,");
            }
            if (model.Headtext != null)
            {
                strSql.Append("Headtext='" + model.Headtext + "',");
            }
            else
            {
                strSql.Append("Headtext= null ,");
            }
            if (model.Internalorder != null)
            {
                strSql.Append("Internalorder='" + model.Internalorder + "',");
            }
            else
            {
                strSql.Append("Internalorder= null ,");
            }
            if (model.ProfitCenter != null)
            {
                strSql.Append("ProfitCenter='" + model.ProfitCenter + "',");
            }
            else
            {
                strSql.Append("ProfitCenter= null ,");
            }
            if (model.ItemText != null)
            {
                strSql.Append("ItemText='" + model.ItemText + "',");
            }
            else
            {
                strSql.Append("ItemText= null ,");
            }
            if (model.ItemText2 != null)
            {
                strSql.Append("ItemText2='" + model.ItemText2 + "',");
            }
            else
            {
                strSql.Append("ItemText2= null ,");
            }
            if (model.Remark != null)
            {
                strSql.Append("Remark='" + model.Remark + "',");
            }
            else
            {
                strSql.Append("Remark= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

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

            if (model.iID != null)
            {
                strSql1.Append("iID,");
                strSql2.Append("" + model.iID + ",");
            }
            if (model.Creater != null)
            {
                strSql1.Append("Creater,");
                strSql2.Append("'" + model.Creater + "',");
            }
            if (model.CreateDate != null)
            {
                strSql1.Append("CreateDate,");
                strSql2.Append("'" + model.CreateDate + "',");
            }
            if (model.SalesType != null)
            {
                strSql1.Append("SalesType,");
                strSql2.Append("'" + model.SalesType + "',");
            }
            if (model.Headtext != null)
            {
                strSql1.Append("Headtext,");
                strSql2.Append("'" + model.Headtext + "',");
            }
            if (model.GLCode != null)
            {
                strSql1.Append("GLCode,");
                strSql2.Append("'" + model.GLCode + "',");
            }
            if (model.Internalorder != null)
            {
                strSql1.Append("Internalorder,");
                strSql2.Append("'" + model.Internalorder + "',");
            }
            if (model.ProfitCenter != null)
            {
                strSql1.Append("ProfitCenter,");
                strSql2.Append("'" + model.ProfitCenter + "',");
            }
            if (model.ItemText != null)
            {
                strSql1.Append("ItemText,");
                strSql2.Append("'" + model.ItemText + "',");
            }
            if (model.ItemText2 != null)
            {
                strSql1.Append("ItemText2,");
                strSql2.Append("'" + model.ItemText2 + "',");
            }
            if (model.Remark != null)
            {
                strSql1.Append("Remark,");
                strSql2.Append("'" + model.Remark + "',");
            }
            strSql.Append("insert into _SalesSet(");
            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());
        }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string sErr   = "";
            int    iCount = 0;

            try
            {
                gridView1.PostEditor();

                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;
                        }

                        Model._SalesSet model = new UFIDA.U8.UAP.CustomApp.ControlForm.Model._SalesSet();
                        model.SalesType     = gridView1.GetRowCellValue(i, gridColSalesType).ToString().Trim();
                        model.GLCode        = gridView1.GetRowCellValue(i, gridColGLCode).ToString().Trim();
                        model.Headtext      = gridView1.GetRowCellValue(i, gridColHeadtext).ToString().Trim();
                        model.Internalorder = gridView1.GetRowCellValue(i, gridColInternalorder).ToString().Trim();
                        model.ItemText      = gridView1.GetRowCellValue(i, gridColItemText).ToString().Trim();
                        model.ItemText2     = gridView1.GetRowCellValue(i, gridColItemText2).ToString().Trim();
                        model.ProfitCenter  = gridView1.GetRowCellValue(i, gridColProfitCenter).ToString().Trim();

                        model.Remark = gridView1.GetRowCellValue(i, gridColRemark).ToString().Trim();

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

                            DAL._SalesSet dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._SalesSet();
                            sSQL   = dal.Add(model);
                            iCount = iCount + DbHelperSQL.ExecuteNonQuery(tran, CommandType.Text, sSQL);
                        }
                        else
                        {
                            model.Creater    = gridView1.GetRowCellValue(i, gridColCreateUid).ToString().Trim();
                            model.CreateDate = BaseFunction.ReturnDate(gridView1.GetRowCellValue(i, gridColCreateDate));
                            DAL._SalesSet dal = new UFIDA.U8.UAP.CustomApp.ControlForm.DAL._SalesSet();
                            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);
            }
        }