예제 #1
0
파일: DAEBase.cs 프로젝트: Lonfar/PURCHASE
        public virtual string Delete(ArrayList alDeleteData)
        {
            string sqlDelete = "SET   XACT_ABORT   ON begin TRANSACTION  Deletetran ";
            string errMsg    = "";

            for (int i = 0; i < alDeleteData.Count; i++)
            {
                string _tbname      = ((IDeleteEventDate)alDeleteData[i]).TableName;
                string _pkFieldName = ((IDeleteEventDate)alDeleteData[i]).PkName;
                string pkValue      = ((IDeleteEventDate)alDeleteData[i]).PkValue;
                sqlDelete  = sqlDelete + ConstructDMLSql.ConstructDeleteSql(_tbname, _pkFieldName, pkValue) + ";";
                sqlDelete += "   IF @@ERROR<>0 begin  ROLLBACK TRANSACTION  Deletetran return end  ";
            }
            sqlDelete += " else COMMIT TRANSACTION Deletetran ";
            if (sqlDelete.Trim().Length == 0)
            {
                return(ERR_DAE_DELETE);
            }
            try
            {
                errMsg = _da.ExecuteDMLSQL(sqlDelete);
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                return(GetDataBaseErrorsMessage(e));
            }
            return(errMsg);
        }
예제 #2
0
파일: DAEBase.cs 프로젝트: Lonfar/PURCHASE
        private string SaveRowsData(string tableName, DataRow dr, string pkName, string busPKName)
        {
            string sql     = "";
            string errMsg  = "";
            string pkValue = "";

            if (dr.RowState == DataRowState.Deleted)
            {
                dr.RejectChanges();
                sql = ConstructDMLSql.ConstructDeleteSql(tableName, pkName, dr[pkName].ToString());
            }
            else
            {
                if (dr["RowStatus"].ToString().ToUpper() == "NEW")
                {
                    sql = ConstructDMLSql.ConstructInsertSql(tableName, dr);
                }
                else if (dr["RowStatus"].ToString().ToUpper() == "EDIT")
                {
                    if (CheckTimeStampExistForUpdate("", ""))
                    {
                        sql = ConstructDMLSql.ConstructUpdateSql(tableName, dr, pkName, pkValue);
                    }
                }
            }
            try
            {
                errMsg += _da.ExecuteDMLSQL(sql);
                dr.AcceptChanges();
                if (dr["RowStatus"].ToString().ToUpper() == "NEW" && errMsg.Trim().Length == 0)
                {
                    dr["RowStatus"] = "EDIT";
                }
            }
            catch (SqlException e)
            {
                errMsg += GetDataBaseErrorsMessage(e);
            }
            return(errMsg);
        }