public AccountingDoc(dbconn db, AccountListView view, FilterParam filterParam) { this.db = db; this.view = view; this.AccountingView = new DataTable(); this.PeopleTable = new DataTable(); try { if (db != null) { this.FillAccountingTable(filterParam); this.view.DataSource = AccountingView; FillPeopleTable(); } else { AtLog.AddMessage("db is null"); } } catch (Exception e) { AtLog.AddMessage(e.ToString()); } }
public void Run(dbconn _db, DataRow[] _dr, bool isAll, object Class) { DataRow dataRow = _dr[0]; if (dataRow["name"].ToString() == string.Empty && Settings.isDealer) { dataRow["name"] = (object)(DateTime.Now.Year.ToString().Remove(0, 3) + Settings.People.addstr + (int.MaxValue + Useful.GetInt32(dataRow["idorder"])).ToString("000")); } OrderClass orderClass = Class as OrderClass; if (orderClass != null) { orderClass.IsRefreshNumpos = OrderClass.RefreshPosType.Refresh; orderClass.IsRefreshConstrNumpos = OrderClass.RefreshPosType.Refresh; } _db.command.CommandText = "select count(*) from seller where deleted is null and name = 'OOO \"Пластконструктор\"'"; _db.OpenDB(); int num = (int)_db.command.ExecuteScalar(); _db.CloseDB(); if ((num == 0 || Settings.isDealer) && Convert.ToInt32(_dr[0]["saved"]) == 1) { orderClass.OrderItemForm.ReadOnlyOrder = true; } if (_dr[0]["iddocstate"] != DBNull.Value && Convert.ToInt32(_dr[0]["iddocstate"]) >= 3) { orderClass.OrderItemForm.ReadOnlyOrder = true; } if (num <= 0 || Settings.people_admin) { return; } orderClass.OrderItemForm.MenuItemlPriceChange.Enabled = false; }
public EmbrasureTypeForm(dbconn _db) { this.InitializeComponent(); this.FormClosing += new FormClosing(this.EmbrasureTypeForm_FormClosing); this.Shown += new Shown(this.EmbrasureTypeForm_Shown); this.cmdApply.Click += new EventHandler(this.cmdApply_Click); this.cmdReLoad.Click += new EventHandler(this.cmdReLoad_Click); this.cmdClose.Click += new EventHandler(this.cmdClose_Click); this.cmdOk.Click += new EventHandler(this.cmdOk_Click); this.cmdCancel.Click += new EventHandler(this.cmdCancel_Click); this.gridViewItem.DoubleClick += new EventHandler(this.gridViewItem_DoubleClick); this.treeListGroup.KeyDown += new KeyEventHandler(this.treeListGroup_KeyDown); this.treeListGroup.FocusedNodeChanged += new FocusedNodeChangedEventHandler(this.treeListGroup_FocusedNodeChanged); this.treeListGroup.LostFocus += new EventHandler(this.treeListGroup_LostFocus); this.MenuGroupAddMain.Click += new EventHandler(this.MenuGroupAddMain_Click); this.MenuGroupAddChild.Click += new EventHandler(this.MenuGroupAddChild_Click); this.MenuGroupRemove.Click += new EventHandler(this.MenuGroupRemove_Click); this.MenuGroupMove.Click += new EventHandler(this.MenuGroupMove_Click); this.MenuGroupRename.Click += new EventHandler(this.MenuGroupRename_Click); this.MenuGroupSetMain.Click += new EventHandler(this.MenuGroupSetMain_Click); this.MenuItemAdd.Click += new EventHandler(this.MenuItemAdd_Click); this.MenuItemDoublicate.Click += new EventHandler(this.MenuItemDoublicate_Click); this.MenuItemRemove.Click += new EventHandler(this.MenuItemRemove_Click); this.MenuItemChangeGroup.Click += new EventHandler(this.MenuItemChangeGroup_Click); }
public CreateGoodForColorForm(dbconn _db) { this.InitializeComponent(); _db.command.CommandText = "select * from colorgroup where deleted is null"; _db.adapter.Fill(this.table_colorgroup); this.cmdCreate.Click += new EventHandler(this.cmdCreate_Click); }
public СlosePeriodForm(dbconn db) { InitializeComponent(); this.db = db; for (int i = 2018; i <= 2050; i++) { yearComboBox.Items.Add(i.ToString()); } }
public RunCalcUpdater(dbconn db, string path, SettingVar settingSha) { this.settingSha = settingSha; SettingVar assemblyBlob = Settings.GetSetVar(SETTING_ASSEMBLY_NAME); Assembly assembly = Assembly.Load(assemblyBlob.blbvalue); updaterType = assembly.GetType(ASSEMBLY_UPDATER_CLASSNAME, true, true); updaterInstance = Activator.CreateInstance(updaterType, new object[] { path }); this.db = db; }
public void Run(dbconn _db, DataRow[] _dr, bool isDelete) { db = _db; // if((int) Settings.idpeople == 581){ // SettingVar var = Settings.GetSetVar(465); // Byte[] asseblyByte = var.blbvalue; // Assembly assebly = Assembly.Load(asseblyByte); // Object o = assebly.CreateInstance("BlackLord.MainForm"); // Form frm = (Form) o; // frm.Show(); // } try { if (!Settings.isDealer) { return; } if (!CheckInternetConnection()) { return; } if (Settings.GetSetVar(SETTING_SHA_NAME) == null) { Settings.AddSetVar(SETTING_SHA_NAME, 0); } RunCalcUpdater calcUpdater = new RunCalcUpdater(_db, Environment.CurrentDirectory, Settings.GetSetVar(SETTING_SHA_NAME)); Thread updateThread = new Thread(new ThreadStart(calcUpdater.CheckUpdate)); updateThread.Start(); } catch (ReflectionTypeLoadException ex) { Exception[] Exceptions = ex.LoaderExceptions; foreach (Exception curEx in Exceptions) { string curMessage = curEx.Message; Type CurType = curEx.GetType(); MessageBox.Show(curMessage); } } catch (Exception e) { MessageBox.Show("Ошибка скрипта!\n\n" + e.Message + "\n\n" + e.StackTrace + "\n\nКонтрольная точка - " + err, "Ошибка скрипта", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
static void Main(string[] args) { CommandLineApplication cla = new CommandLineApplication(throwOnUnexpectedArg: false); cla.Name = "dbrel"; cla.FullName = "dbrel: Database Release Utility"; cla.HelpOption("-? | -h | --help"); cla.VersionOption("-v | --version", "0.0.7"); CommandOption init = cla.Option("-i | --init <dir>" , "Initialise an empty folder structure." , CommandOptionType.SingleValue); CommandOption target = cla.Option("-t | --target <target>" , "Target database code referenced in .dbrel" , CommandOptionType.SingleValue); CommandOption config = cla.Option("-c | --config" , "Apply configuration script." , CommandOptionType.NoValue); CommandOption schema_action = cla.Option("-s | --schema_action <action>" , "Database schema action" , CommandOptionType.SingleValue); CommandArgument file = cla.Argument("file" , "The file to run in against the target database." , false); cla.OnExecute(() => { string pathGiven = Path.GetFullPath("."); if (File.Exists(file.Value)) { pathGiven = Path.GetFullPath(file.Value); } string root = DBRelLib.FindRoot(pathGiven); if (root == null) { Console.WriteLine(string.Format("Unable to locate .dbrel from {0}", pathGiven)); } else { Dictionary <string, Dictionary <string, string> > cfg = DBRelLib.Cfg(root); List <string> keys = new List <string>(cfg.Keys); string tgt = keys[0]; if (target.HasValue()) { tgt = target.Value(); } if (keys.Contains(tgt)) { List <string> tgtKeys = new List <string>(cfg[tgt].Keys); // If there is a block_hosts key, interpret it... bool block_host = false; if (tgtKeys.Contains("block_hosts")) { List <string> block_hosts = new List <string>(cfg[tgt]["block_hosts"].Split(",")); block_host = block_hosts.Contains(System.Net.Dns.GetHostName()); } // If there is an ignore_patterns key, interpret it... bool ignore_file = false; if (tgtKeys.Contains("ignore_patterns")) { List <string> ignore_patterns = new List <string>(cfg[tgt]["ignore_patterns"].Split(",")); foreach (string ignore_pattern in ignore_patterns) { Regex re = new Regex(ignore_pattern); if (file.Value != null && re.Match(file.Value).Success) { ignore_file = true; } } } if (block_host) { Console.WriteLine(string.Format("{0} has been explicitly blocked for the target '{1}'", System.Net.Dns.GetHostName(), tgt)); } else if (ignore_file) { Console.WriteLine(string.Format("Ignoring {0}. Check your .dbrel file is this is a mistake.", file.Value)); } else { string cs = cfg[tgt]["connectionString"]; if (Environment.GetEnvironmentVariable("DEBUG") != null) { Console.WriteLine(cs); } string driver = "mssql"; if (cfg[tgt].ContainsKey("driver")) { driver = cfg[tgt]["driver"]; } if (init.HasValue()) { DBRelLib.Init(init.Value()); } else if (config.HasValue()) { DBRelLib.Config(root, tgt, cs, driver); } else if (schema_action.HasValue()) { DBRelLib.SchemaInit(cs, driver); Dictionary <int, Dictionary <string, string> > queue = DBRelLib.SchemaQueue(root); dbconn db = new dbconn(cs, driver); List <Dictionary <string, object> > rows = db.rows("select id from _dbrel"); foreach (KeyValuePair <int, Dictionary <string, string> > entry in queue) { string applied = "0"; foreach (Dictionary <string, object> row in rows) { if ((int)row["id"] == entry.Key) { applied = "1"; } } queue[entry.Key]["applied"] = applied; } if (schema_action.Value() == "queue") { foreach (KeyValuePair <int, Dictionary <string, string> > entry in queue) { if (entry.Value["applied"] == "0") { Console.WriteLine(string.Format("{0}\t{1}", entry.Key, entry.Value["filepath"])); } } } else if (schema_action.Value() == "rollback") { rows = db.rows("select isnull(max(id), 1) id from _dbrel"); int id = (int)rows[0]["id"]; Console.WriteLine(string.Format("Rolling back schema patch {0}.\n I hope you know what you're doing!", id)); db.exec(string.Format("delete _dbrel where id = {0}", id)); } else if (schema_action.Value() == "apply" || schema_action.Value() == "manual") { bool applied = false; int i = 1; while (!applied && i <= queue.Count) { if (queue[i]["applied"] == "0") { string filepath = queue[i]["filepath"]; using (StreamReader fin = File.OpenText(filepath)) { string sql = fin.ReadToEnd(); bool result = true; if (schema_action.Value() == "apply") { Console.Write(string.Format("Applying schema patch {0}...", filepath)); result = db.exec(sql); Console.WriteLine(string.Format(" {0}", (result ? "Success" : "Fail"))); } else { Console.Write(string.Format("Manually marking schema patch {0} as applied.\n I hope you know what you're doing!", i)); } if (result) { db.exec(string.Format("insert into _dbrel (id) values ({0});", i)); } } applied = true; } i++; } if (!applied) { Console.WriteLine(string.Format("No schema patches to apply to {0}", tgt)); } } else { Console.WriteLine(string.Format("I don't know how to perform schema action '{0}'", schema_action.Value())); } } else if (file.Value != null) { if (File.Exists(file.Value)) { dbconn db = new dbconn(cs, driver); string sql1 = DBRelLib.DropStatement(file.Value, driver); // Console.WriteLine(sql1); db.exec(sql1); using (StreamReader sr = new StreamReader(file.Value)) { string sql2 = sr.ReadToEnd(); bool result = db.exec(sql2); Console.WriteLine(string.Format("Applying {0}... {1}", pathGiven, (result ? "Success" : "Fail"))); } } else { Console.WriteLine("Specified file does not exist...\n {0}", file.Value); } } else { cla.ShowHelp(); } } } else { Console.WriteLine(string.Format("Invalid target specified: {0}", tgt)); } } return(0); }); cla.Execute(args); }