public int SaveDocument(IdentityObject ident, string _tableName, string inDocNum, string inDocType, List <string> myData) { int retCode = 0; // DocNum = inDocNum; DocNum = Int32.Parse(inDocNum); DocType = Int32.Parse(inDocType); string cmdString = String.Format("insert into {0} Values ({1})", _tableName.Trim(), myData[0]); //where DocNum = {1} and DocType = {2}", _tableName, inDocNum, inDocType); string retMessage = DataBaseUtility.Execute(cmdString, ident); // if (mainString.Count < 2) return 0; // if (mainString.Count > 2) return 3; // count = 2, therefore found 1 data record and 1 string of names // new GenDoc(mainString[1]); // cmdString = String.Format("select * from DocumentDetails where DucNum = {0} and DocType = {1}, inDocNum, inDocType"); // List<string> detailStrings = DbUtility.GetList(cmdString); if (myData.Count < 2) { return(0); } for (int i = 1; i < myData.Count; i++) { string cmdString2 = String.Format("insert into {0}_Details Values ({1})", _tableName.Trim(), myData[i]); string retMessage2 = DataBaseUtility.Execute(cmdString2, ident); } return(retCode); }
public static int Execute(IdentityObject ident, string _sqlCommand) { // int retcode = 0; //string _message = "no errors"; //OleDbConnection conn; //conn = GetConnectionObject(); DB_Operations db = new DB_Operations(); try { //if (ident.ActionLevel < 5) //{ // // _message = "command requires a higher permission level than " + ident.ActionLevel + " by user : "******"could not execute " + _sqlCommand; } else { return(0); // "no errors"; } } catch (Exception) { return(2); // (e.ToString()); } }
public static string Execute(string _sqlCommand, IdentityObject ident) { string _message = "no errors"; //OleDbConnection conn; //conn = GetConnectionObject(); //try //{ //if (ident.ActionLevel < 5) //{ // _message = "command requires a higher permission level than " + ident.ActionLevel + " by user : "******"could not execute " + _sqlCommand; return(_message); } else { return("no errors"); } //} //catch (Exception e) //{ // return (e.ToString()); //} //finally }
protected void SetIdentityObject(IdentityObject _ident) { UserID = _ident.UserID; UserName = _ident.UserName; Role = _ident.Role; ActionLevel = _ident.ActionLevel; Dept = _ident.Dept; }
public static void DeleteEntity(IdentityObject ident, string _tablename, string docNumStr, string docTypeStr) { // OleDbConnection conn = GetConnectionObject(); //if (ident.ActionLevel < 5) //{ // _message = "command requires a higher permission level than " + ident.ActionLevel + " by user : "******"delete from {0} where DocNum = {1} ", _tablename, docNum); //, docType); //where DocNum = {1}",/* and //OleDbCommand cmd = new OleDbCommand(cmdStr, conn); //conn.Open(); //cmd.ExecuteNonQuery(); db.InsertUpdateDeleteQry(cmdStr); } catch (Exception e) { //MessageBox.Show("Error Report: " + e.Message); } //finally //{ // conn.Close(); //} try { int docNum = Int32.Parse(docNumStr); int docType = Int32.Parse(docTypeStr); string cmdStr2 = String.Format("delete from {0}_Details where DocNum = {1} ", _tablename, docNum); //, docType); //where DocNum = {1}",/* and //OleDbCommand cmd2 = new OleDbCommand(cmdStr2, conn); //conn.Open(); //cmd2.ExecuteNonQuery(); db.InsertUpdateDeleteQry(cmdStr2); } catch (Exception) { // MessageBox.Show("Error Report: " + e.Message); } //finally //{ // conn.Close(); //} }