void CopyDecryptApartment(DamaiDataSet.ApartmentRow enc, DamaiDataSet.ApartmentRow dec) { dec.ApartmentID = enc.ApartmentID; if (!enc.IsApartmentAllNameNull()) { dec.ApartmentAllName = enc.ApartmentAllName; } if (!enc.IsApartmentNameNull()) { dec.ApartmentName = enc.ApartmentName; } if (!enc.IsAppartementCodeNull()) { dec.AppartementCode = enc.AppartementCode; } DataRow encR = (DataRow)enc; DataRow decR = (DataRow)dec; foreach (string col in ColumnsEncryted) // 這種寫法不檢查 IsNull, 所以這欄不准Null { try { if (encR[col].ToString() == "") { decR[col] = ""; continue; } byte[] buf = Encoder.RC2Decrypt(Convert.FromBase64String(encR[col].ToString()), Key); decR[col] = Encoding.Unicode.GetString(buf); } catch (Exception ex) { } // 資料有問題不處理 } }
void EncryptCopyApartment(DamaiDataSet.ApartmentRow plainRow, DamaiDataSet.ApartmentDataTable encryptedTable) { var row = encryptedTable.FindByApartmentID(plainRow.ApartmentID); bool isNew = (row == null); if (isNew) { row = encryptedTable.NewApartmentRow(); row.ApartmentID = plainRow.ApartmentID; } if (!plainRow.IsApartmentAllNameNull()) { row.ApartmentAllName = plainRow.ApartmentAllName; } if (!plainRow.IsApartmentNameNull()) { row.ApartmentName = plainRow.ApartmentName; } if (!plainRow.IsAppartementCodeNull()) { row.AppartementCode = plainRow.AppartementCode; } DataRow encR = (DataRow)row; DataRow plainR = (DataRow)plainRow; foreach (string col in ColumnsEncryted) // 這種寫法不檢查 IsNull, 所以這欄不准Null { try { string str = plainR[col].ToString().Trim(); if (str == "") { encR[col] = ""; continue; } byte[] buf = Encoder.RC2Encrypt(Encoding.Unicode.GetBytes(str), Key); encR[col] = Convert.ToBase64String(buf); } catch (Exception ex) { } // 資料有問題不處理 } if (isNew) { encryptedTable.AddApartmentRow(row); } }
public FormShipment(DamaiDataSet.ApartmentRow apartment) { m_DefaultApartment = apartment; InitializeComponent(); }
private bool ReadTable() { operatorSQLAdapter = new DamaiDataSetTableAdapters.OperatorTableAdapter(); headerSQLAdapter = new DamaiDataSetTableAdapters.VEHeaderTableAdapter(); apartmentSQLAdapter = new DamaiDataSetTableAdapters.ApartmentTableAdapter(); authListSQLAdapter = new DamaiDataSetTableAdapters.OperatorAuthListTableAdapter(); operatorSQLAdapter.Connection.ConnectionString = DB.SqlConnectString(m_Cfg); apartmentSQLAdapter.Connection.ConnectionString = DB.SqlConnectString(m_Cfg); authListSQLAdapter.Connection.ConnectionString = DB.SqlConnectString(m_Cfg); damaiDataSet = new DamaiDataSet(); try { operatorSQLAdapter.Fill(damaiDataSet.Operator); headerSQLAdapter.Fill(damaiDataSet.VEHeader); apartmentSQLAdapter.Fill(damaiDataSet.Apartment); authListSQLAdapter.Fill(damaiDataSet.OperatorAuthList); } catch (Exception ex) { MessageBox.Show("操作員資料庫讀取錯誤<" + ex.Message + ">! 無法登入"); return(false); } if (damaiDataSet.Operator.Rows.Count == 0) { MessageBox.Show("資料庫內沒有設定任何操作員,無法登入"); Close(); return(false); } if (damaiDataSet.Apartment.Rows.Count != 0) { string Key = "LordAlex"; foreach (var a in damaiDataSet.Apartment) { byte[] buf = Encoder.RC2Decrypt(Convert.FromBase64String(a.DatabaseName.Trim()), Key); string decoded = Encoding.Unicode.GetString(buf); if (decoded == m_Cfg.Database.Trim()) // 不使用IsCurrent了 { m_DefaultApartment = a; break; } } if (m_DefaultApartment == null) { MessageBox.Show("部門資料庫內找不到<" + m_Cfg.Database + ">,設定有誤無法登入,請找IT帥哥!"); #if (DEBUG) m_DefaultApartment = damaiDataSet.Apartment[9]; #else Close(); return(false); #endif } } DamaiDataSet.VEHeaderRow header = null; string sVersion = ""; if (damaiDataSet.VEHeader.Count > 0) { header = damaiDataSet.VEHeader[0]; if (!header.IsVersionNull()) { sVersion = header.Version.Trim(); } } CheckAppVersion(sVersion); return(true); }
public FormBillList(DamaiDataSet.ApartmentRow defaultApartment) { m_DefaultApartment = defaultApartment; InitializeComponent(); }
public FormHome(COperator Op, HardwareConfig cfg, DamaiDataSet.ApartmentRow apartment, DamaiDataSet.ApartmentDataTable authorizedApartment) { InitializeComponent(); Operator = Op; MyFunction.OperatorID = Op.OperatorID; MyFunction.HardwareCfg = m_Config = cfg; m_DefaultApartment = apartment; m_AuthorizedApartment = authorizedApartment; SetFormTitle(); ToolStripMenuItem basic, accounting, bank, it; basic = (ToolStripMenuItem)menu1.Items["基本資料MenuItem"]; accounting = (ToolStripMenuItem)menu1.Items["會計MenuItem"]; it = (ToolStripMenuItem)menu1.Items["IT維護MenuItem"]; bank = (ToolStripMenuItem)menu1.Items["銀行MenuItem"]; basic.Enabled = (Op.EditEmployee | Op.EditOperator | Op.EditIngredient | Op.EditVendor); accounting.Enabled = Op.EditAccountingTitle; it.Enabled = Op.IsSuper; bank.Enabled = Op.EditBank; bool manager = Op.IsManager; MyFunction.IsManager = manager; MyFunction.LockHR = Op.LockHR; MyFunction.LockInventory = Op.LockInventory; basic.DropDownItems["食材表MenuItem"].Enabled = Op.EditIngredient; basic.DropDownItems["配方表MenuItem"].Enabled = Op.EditRecipe; basic.DropDownItems["產品表MenuItem"].Enabled = Op.EditProduct; basic.DropDownItems["产品类别ToolStripMenuItem"].Enabled = Op.EditProduct; basic.DropDownItems["編修菜單MenuItem"].Enabled = Op.EditProduct; basic.DropDownItems["供應商MenuItem"].Enabled = Op.EditVendor; basic.DropDownItems["客户MenuItem"].Visible = Op.EditCustomer; 轉帳傳票MenuItem.Enabled = Op.EditAccountingTitle; // 傳票和會計科目 accounting.DropDownItems["會計科目MenuItem"].Enabled = Op.LockAccVoucher && Op.EditAccountingTitle; accounting.DropDownItems["傳票設定MenuItem"].Visible = Op.LockAccVoucher && Op.EditAccountingTitle; // 核傳票+編修科目 bank.DropDownItems["銀行帳號MenuItem"].Enabled = Op.EditBank; bank.DropDownItems["銀行帳號MenuItem"].Visible = Op.EditBank; it.DropDownItems["操作員MenuItem"].Enabled = Op.EditOperator; it.DropDownItems["硬體環境MenuItem"].Enabled = Op.IsSuper; it.DropDownItems["年初開帳MenuItem"].Visible = Op.IsSuper; it.DropDownItems["編修部門MenuItem"].Visible = Op.IsSuper; menu1.Items["庫存MenuItem"].Enabled = Op.EditInventory; menu1.Items["費用MenuItem"].Enabled = Op.EditExpense; menu1.Items["進貨MenuItem"].Enabled = Op.EditVoucher; menu1.Items["收入MenuItem"].Enabled = Op.RevenueOperate; menu1.Items["報表MenuItem"].Enabled = manager; ToolStripMenuItem i = (ToolStripMenuItem)menu1.Items["查核MenuItem"]; i.Enabled = Op.LockExpense || Op.LockVoucher || Op.LockAccVoucher; 查核費用MenuItem.Enabled = Op.LockExpense; 查核進貨MenuItem.Enabled = Op.LockVoucher; 查核傳票MenuItem.Enabled = Op.LockAccVoucher; 人事MenuItem.Enabled = Op.EditSalary || Op.EditOnDuty || Op.LockHR; 考勤MenuItem.Enabled = Op.EditOnDuty; 排班表MenuItem.Enabled = Op.EditOnDuty; 資料卡MenuItem.Enabled = Op.EditSalary; 出货MenuItem.Enabled = Op.EditShipment || Op.LockShipment; if (m_AuthorizedApartment.Rows.Count <= 1) // 只有一家店可登入的就不顯示了 { 切換門店MenuItem.Enabled = false; } if (MyFunction.LockAll) { i.DropDownItems["鎖定資料庫MenuItem"].Text = "解鎖資料庫"; } else { i.DropDownItems["鎖定資料庫MenuItem"].Text = "鎖定資料庫"; } foreach (ToolStripMenuItem item in menu1.Items) { if (!item.Enabled) { item.Visible = false; } else { foreach (ToolStripMenuItem its in item.DropDownItems) { if (!its.Enabled) { its.Visible = false; } } } } }