//ModernDialog_Loaded private void ModernDialog_Loaded(object sender, RoutedEventArgs e) { try { //GetPayment GetPayment(1); //disable btnSaveInvoice btnEnter.IsEnabled = false; btnSaveInvoice.IsEnabled = false; btnSaveSendEmail.IsEnabled = false; total = StaticClass.GeneralClass.subtotal_general + StaticClass.GeneralClass.totaltaxrate_general - StaticClass.GeneralClass.totaldiscount_general; tblTotalUnit.Text = StaticClass.GeneralClass.currency_setting_general; tblTotal.Text = StaticClass.GeneralClass.GetNumFormatDisplay(total); tblPayCashUnit.Text = StaticClass.GeneralClass.currency_setting_general; tblPayCash.Text = "0"; tblCashBalanceUnit.Text = StaticClass.GeneralClass.currency_setting_general; tblCashBalance.Text = StaticClass.GeneralClass.GetNumFormatEdit(0); } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//UserControl_Loaded private void UserControl_Loaded(object sender, RoutedEventArgs e) { flag_zero_load = false; //handle control HandleControl(); try { dttb_user = bus_tb_user.GetUser("WHERE [ID]=" + StaticClass.GeneralClass.id_user_general); if (dttb_user.Rows.Count > 0) { tblID.Text = dttb_user.Rows[0]["ID"].ToString(); tblUserName.Text = dttb_user.Rows[0]["Name"].ToString(); txbEmail.Text = dttb_user.Rows[0]["Email"].ToString(); txbAddress.Text = dttb_user.Rows[0]["Address"].ToString(); txbQuestion.Text = dttb_user.Rows[0]["Question"].ToString(); txbAnswer.Text = dttb_user.Rows[0]["Answer"].ToString(); flag_zero_load = true; } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//EncryptFile //key must be 64bits, 8 byte public void EncryptFile(string customername, string serialnumber, string inputfilename, string outputfilename, string key) { try { StreamWriter stream_writer = new StreamWriter(inputfilename); stream_writer.WriteLine("CustomerEmail:" + customername); stream_writer.WriteLine("SerialNumber:" + serialnumber); stream_writer.Close(); FileStream filestream_input = new FileStream(inputfilename, FileMode.Open, FileAccess.Read); FileStream filestream_encrypted = new FileStream(outputfilename, FileMode.Create, FileAccess.Write); DESCryptoServiceProvider desCtoSP = new DESCryptoServiceProvider(); desCtoSP.Key = ASCIIEncoding.ASCII.GetBytes(key); desCtoSP.IV = ASCIIEncoding.ASCII.GetBytes(key); ICryptoTransform ICtoTf = desCtoSP.CreateEncryptor(); CryptoStream CtoS = new CryptoStream(filestream_encrypted, ICtoTf, CryptoStreamMode.Write); byte[] bytearrayinput = new byte[filestream_input.Length]; filestream_input.Read(bytearrayinput, 0, bytearrayinput.Length); CtoS.Write(bytearrayinput, 0, bytearrayinput.Length); CtoS.Close(); filestream_input.Close(); System.IO.File.Delete(inputfilename); filestream_encrypted.Close(); } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = "Error: " + ex.Message; page.ShowDialog(); } }
//enter press private bool EnterPress() { try { paycash = Convert.ToDecimal(tblPayCash.Text.Trim(), StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0" ? new System.Globalization.CultureInfo("en-US") : new System.Globalization.CultureInfo("fr-FR")); if (paycash > 0) { //enable save invoice btnSaveInvoice.IsEnabled = true; btnSaveSendEmail.IsEnabled = true; if (total > paycash) { tblCashBalance.Text = "-" + StaticClass.GeneralClass.GetNumFormatDisplay(total - paycash); } else { tblCashBalance.Text = StaticClass.GeneralClass.GetNumFormatDisplay(paycash - total); } return(true); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } return(false); }
//txbEmail_TextChanged private void txbEmail_TextChanged(object sender, TextChangedEventArgs e) { if (flag_zero_load == true) { try { EC_tb_User ec_tb_user = GetUser(); HandleControl(); imgEmail.Visibility = System.Windows.Visibility.Visible; if (bus_tb_user.UpdateUser(ec_tb_user, StaticClass.GeneralClass.flag_database_type_general) == 1) { imgEmail.Source = ok_bitmapimage; } else { imgEmail.Source = failed_bitmapimage; } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } } }
//btnTbInputDetail_Click private void btnTbInputDetail_Click(object sender, RoutedEventArgs e) { try { DataTable tb_inputhistory = new DataTable(); tb_inputhistory = GetTableImport("tb_InputHistory"); if (tb_inputhistory.Rows.Count > 0) { if (bus_tb_inputhistory.GetInputHistory("").Rows.Count > 0) { bus_tb_inputhistory.DeleteAllInputHistory(); } } if (InSertAllInputHistory(tb_inputhistory) > 0) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = "Import success!"; page.ShowDialog(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//btnTbSalesperson_Click private void btnTbSalesperson_Click(object sender, RoutedEventArgs e) { try { DataTable tb_salesperson = new DataTable(); tb_salesperson = GetTableImport("tb_Salesperson"); if (tb_salesperson.Rows.Count > 0) { if (bus_tb_salesperson.GetSalesPerson("").Rows.Count > 0) { bus_tb_salesperson.DeleteAllSalesPerson(); } } if (InSertAllSalesperson(tb_salesperson) > 0) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = "Import success!"; page.ShowDialog(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//btnTbProduct_Click private void btnTbProduct_Click(object sender, RoutedEventArgs e) { try { DataTable tb_product = new DataTable(); tb_product = GetTableImport("tb_Product"); if (tb_product.Rows.Count > 0) { if (bus_tb_product.GetProduct("").Rows.Count > 0) { bus_tb_product.DeleteAllProduct(); } } if (InSertAllProduct(tb_product) > 0) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = "Import success!"; page.ShowDialog(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//btnTbSetting_Click private void btnTbSetting_Click(object sender, RoutedEventArgs e) { try { DataTable tb_setting = new DataTable(); tb_setting = GetTableImport("tb_Currency"); if (tb_setting.Rows.Count > 0) { if (bus_tb_setting.GetSetting("").Rows.Count > 0) { bus_tb_setting.DeleteAllSetting(); } } if (InSertAllSetting(tb_setting) > 0) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = "Import success!"; page.ShowDialog(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//DecryptFile public string[] DecryptFile(string inputfilename, string key) { string[] arr_register = null; try { DESCryptoServiceProvider DESCtoSP = new DESCryptoServiceProvider(); DESCtoSP.Key = ASCIIEncoding.ASCII.GetBytes(key); DESCtoSP.IV = ASCIIEncoding.ASCII.GetBytes(key); FileStream filestream = new FileStream(inputfilename, FileMode.Open, FileAccess.Read); ICryptoTransform ICtoTF = DESCtoSP.CreateDecryptor(); CryptoStream cryptostream = new CryptoStream(filestream, ICtoTF, CryptoStreamMode.Read); StreamReader streamreader = new StreamReader(cryptostream); string customername = streamreader.ReadLine().Split(':')[1].Trim(); string serial_number = streamreader.ReadLine().Split(':')[1].Trim(); streamreader.Close(); arr_register = new string[] { customername, serial_number }; } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = "Error: " + ex.Message; page.ShowDialog(); } return(arr_register); }
//btnTbUser_Click private void btnTbUser_Click(object sender, RoutedEventArgs e) { try { DataTable tb_user = new DataTable(); tb_user = GetTableImport("tb_User"); if (tb_user.Rows.Count > 0) { if (bus_tb_user.GetUser("").Rows.Count > 0) { bus_tb_user.DeleteAllUser(); } } if (InSertAllUser(tb_user) > 0) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = "Import success!"; page.ShowDialog(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//btnTbOrderDetail_Click private void btnTbOrderDetail_Click(object sender, RoutedEventArgs e) { try { DataTable tb_orderdetail = new DataTable(); tb_orderdetail = GetTableImport("tb_OrderDetail"); if (tb_orderdetail.Rows.Count > 0) { if (bus_tb_orderdetail.GetOrderDetail("").Rows.Count > 0) { bus_tb_orderdetail.DeleteAllOrderDetail(""); } } System.Diagnostics.Debug.WriteLine(tb_orderdetail.Rows.Count); if (InSertAllOrderDetail(tb_orderdetail) > 0) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = "Import success!"; page.ShowDialog(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message + "ex"; page.ShowDialog(); } }
//hplYes_Click private void hplYes_Click(object sender, RoutedEventArgs e) { try { //add and remove title link app.mainWindow.TitleLinks.Remove(app.linkAccount); app.mainWindow.TitleLinks.Remove(app.linkLogout); app.mainWindow.TitleLinks.Add(app.linkLogin); switch (GeneralClass.user_permission) { case (int)GeneralClass.UserPermission.admin: //admin permission app.mainWindow.MenuLinkGroups.Remove(app.linkGroupStatistic); app.mainWindow.MenuLinkGroups.Remove(app.linkGroupChart); app.mainWindow.MenuLinkGroups.Remove(app.linkGroupSetting); app.mainWindow.MenuLinkGroups.Remove(app.linkGroupReport); break; case (int)GeneralClass.UserPermission.inventory: //inventory permission app.mainWindow.MenuLinkGroups.Remove(app.linkGroupSetting); break; case (int)GeneralClass.UserPermission.report: //report permission app.mainWindow.MenuLinkGroups.Remove(app.linkGroupReport); break; } string user_name = GeneralClass.name_user_general; if (!StaticClass.GeneralClass.flag_salespersonlogin_general) { GeneralClass.user_permission = (int)GeneralClass.UserPermission.user; } else { GeneralClass.user_permission = 5; } GeneralClass.id_user_general = 0; GeneralClass.name_user_general = ""; GeneralClass.password_user_general = ""; //save logs if (StaticClass.GeneralClass.app_settings["isSaveLogs"].ToString() == "True") { new System.Threading.Thread(() => { GeneralClass.SaveLogs(user_name, "Logged out", DateTime.Now); }).Start(); } app.mainWindow.ContentSource = new Uri(@"/Pages/Home/Home.xaml", UriKind.Relative); } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//hplChangePassWord_Click private void hplChangePassWord_Click(object sender, RoutedEventArgs e) { try { BBCodeBlock bbcodeblock = new BBCodeBlock(); bbcodeblock.LinkNavigator.Navigate(new Uri("/Pages/Setting/ChangePassword.xaml", UriKind.Relative), this); } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//hplNo_Click private void hplNo_Click(object sender, RoutedEventArgs e) { BBCodeBlock bbcodeblock = new BBCodeBlock(); try { bbcodeblock.LinkNavigator.Navigate(new Uri(@"/Pages/Home/Home.xaml", UriKind.Relative), this); } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//ModernDialog_KeyDown private void ModernDialog_KeyDown(object sender, KeyEventArgs e) { try { int num; if (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") { if (int.TryParse(GetCharFromKey(e.Key).ToString(), out num) || GetCharFromKey(e.Key).ToString() == ".") { Paycash(GetCharFromKey(e.Key).ToString(), true); } } else { if (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "1") { if (int.TryParse(GetCharFromKey(e.Key).ToString(), out num) || GetCharFromKey(e.Key).ToString() == ",") { Paycash(GetCharFromKey(e.Key).ToString(), true); } } } //enter key press if (e.Key.ToString() == "Return") { if (EnterPress()) { btnSaveInvoice.Focus(); btnSaveInvoice.IsEnabled = true; btnSaveSendEmail.IsEnabled = true; } } //back key press if (e.Key.ToString() == "Back") { BackspacePress(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//GetProductQuantity private int GetProductQuantity(List <EC_tb_OrderDetail> list_ec_tb_orderdetail) { int quantity = 0; try { for (int i = 0; i < StaticClass.GeneralClass.list_ec_tb_orderdetail_general.Count; i++) { quantity += StaticClass.GeneralClass.list_ec_tb_orderdetail_general[i].Qty; } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } return(quantity); }
private DataTable GetTableImport(string excel_worksheet) { try { data_table = new DataTable(); openfiledialog = new System.Windows.Forms.OpenFileDialog(); openfiledialog.Filter = "Excel (*.xlsx)|*.xlsx"; if (openfiledialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { data_table = excel_utility.GetDataTableToImport(openfiledialog.FileName, excel_worksheet); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } return(data_table); }
//ModernDialog_KeyDown private void ModernDialog_KeyDown(object sender, KeyEventArgs e) { ShellOutModel msShellout = (ShellOutModel)lstShellOut.Items[lstShellOut.SelectedIndex]; string _strId = msShellout.PaymentId.ToString(); if (_strId.Length >= 3) { _strId = _strId.Remove(2); } if (Convert.ToInt32(_strId) == 11) { return; } ShellOutModel _default = (ShellOutModel)lstShellOut.Items[0]; string _strSeparator = (StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0") ? "." : ","; string strVal = msShellout.PaymentBalance.ToString(); string strkey = GetCharFromKey(e.Key).ToString(); if (GetCharFromKey(e.Key).ToString() == _strSeparator) { if (!msShellout.PaymentBalance.Trim().Contains(strkey)) { strVal += GetCharFromKey(e.Key).ToString(); } msShellout.PaymentBalance = strVal; isEnableInvoice(); } try { int num; if (int.TryParse(GetCharFromKey(e.Key).ToString(), out num)) { string _strCompare = Convert.ToString(StaticClass.GeneralClass.ConverStringToDecimal(strVal)) + strkey; if (Convert.ToDouble(_strCompare) < 999999999.99) { if (msShellout.PaymentId == 1) { if (StaticClass.GeneralClass.ConverStringToDecimal(strVal) == 0) { strVal = GetCharFromKey(e.Key).ToString(); } else { int ind = strVal.IndexOf(_strSeparator); if (ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(ind + 1); if (_strNumberDecimalSeparator.Length < 2) { strVal += GetCharFromKey(e.Key).ToString(); } } else { strVal += GetCharFromKey(e.Key).ToString(); } } int _ind = strVal.IndexOf(_strSeparator); if (_ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(_ind + 1); msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length); } else { msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0); } isEnableInvoice(); } else if (CalculateTotalBalance(msShellout.PaymentId, StaticClass.GeneralClass.ConverStringToDecimal(strVal + strkey)) <= StaticClass.GeneralClass.ConverStringToDecimal(_default.PaymentBalance)) { if (StaticClass.GeneralClass.ConverStringToDecimal(strVal) == 0) { strVal = GetCharFromKey(e.Key).ToString(); } else { int ind = strVal.IndexOf(_strSeparator); if (ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(ind + 1); if (_strNumberDecimalSeparator.Length < 2) { strVal += GetCharFromKey(e.Key).ToString(); } } else { strVal += GetCharFromKey(e.Key).ToString(); } } int _ind = strVal.IndexOf(_strSeparator); if (_ind > 0) { string _strNumberDecimalSeparator = strVal.Substring(_ind + 1); msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), _strNumberDecimalSeparator.Length); } else { msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(StaticClass.GeneralClass.ConverStringToDecimal(strVal), 0); } isEnableInvoice(); } else { ModernDialog md = new ModernDialog(); md.CloseButton.FindResource("close").ToString(); md.Content = App.Current.FindResource("payment_balance_less_cash_balance").ToString(); md.Title = App.Current.FindResource("notification").ToString(); md.ShowDialog(); } } } //enter key press if (e.Key.ToString() == "Return") { //btnEnter_Click(null, null); } //back key press if (e.Key.ToString() == "Back") { string _strVal = msShellout.PaymentBalance.ToString(); if (_strVal.Length == 1) { msShellout.PaymentBalance = "0"; } else { _strVal = _strVal.Remove(_strVal.Length - 1, 1); decimal _tmpDec = StaticClass.GeneralClass.ConverStringToDecimal(_strVal); _strVal = Convert.ToString(_tmpDec); int _ind = _strVal.IndexOf(_strSeparator); if (_ind > 0) { string _strNumberDecimalSeparator = _strVal.Substring(_ind + 1); msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(_tmpDec, _strNumberDecimalSeparator.Length); } else { msShellout.PaymentBalance = StaticClass.GeneralClass.FormatNumberDisplay(_tmpDec, 0); } } isEnableInvoice(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//btnOK_Click private void btnOK_Click(object sender, RoutedEventArgs e) { try { if (txbYourEmail.Text.Trim().ToString() == "") { tblNotification.Text = FindResource("your_email_null").ToString(); txbYourEmail.Focus(); return; } if (txbSerialNumber.Text.Trim().ToString() == "") { tblNotification.Text = FindResource("serial_number_null").ToString(); txbSerialNumber.Focus(); return; } else { SecurityManager scm = new SecurityManager(); string softname = "Cash Register"; string customer_email = txbYourEmail.Text.Trim().ToString(); string license_key_info = softname + "_" + StaticClass.GeneralClass.software_version + "_" + customer_email; string serial_number = txbSerialNumber.Text.Trim().ToString(); if (scm.CheckSerialNumber(license_key_info, serial_number)) { //create register status in regedit Registry.SetValue(StaticClass.GeneralClass.keyname_register_general, StaticClass.GeneralClass.valuename_register_general, "TRUE"); //create register info file Pages.CopyRight.SecurityManager security_manager = new Pages.CopyRight.SecurityManager(); security_manager.EncryptFile(customer_email, serial_number, "ResInfo", "EncryptReg", StaticClass.GeneralClass.key_register_general); Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = FindResource("activation_success").ToString(); page.ShowDialog(); //set registerd successful StaticClass.GeneralClass.flag_registered_general = true; StaticClass.GeneralClass.youremail_registered_general = txbYourEmail.Text.Trim().ToString(); Application.Current.Resources["cash_register"] = "Cash Register Pro"; BBCodeBlock bbcodeblock = new BBCodeBlock(); bbcodeblock.LinkNavigator.Navigate(new Uri(@"/Pages/Settings/About.xaml", UriKind.Relative), this); } else { //if serial number is invalid Registry.SetValue(StaticClass.GeneralClass.keyname_register_general, StaticClass.GeneralClass.valuename_register_general, "FALSE"); Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = FindResource("activation_unsuccess").ToString(); page.ShowDialog(); } } } catch (Exception ex) { //if serial number is invalid and have error Registry.SetValue(StaticClass.GeneralClass.keyname_register_general, StaticClass.GeneralClass.valuename_register_general, "FALSE"); tblNotification.Text = ex.Message; } }
//btnOK_Click private void btnOK_Click(object sender, RoutedEventArgs e) { try { if (pwbCurrentPassword.Password.Trim() == "") { tblNotification.Text = FindResource("current_password_null").ToString(); pwbCurrentPassword.Focus(); return; } if (pwbNewPassword.Password.Trim() == "") { tblNotification.Text = FindResource("new_password_null").ToString(); pwbNewPassword.Focus(); return; } if (pwbNewPassword.Password.Trim().Length < 3) { tblNotification.Text = FindResource("password_short").ToString(); pwbNewPassword.Focus(); return; } if (pwbConfirmPassword.Password.Trim() == "") { tblNotification.Text = FindResource("confirm_password_null").ToString(); pwbConfirmPassword.Focus(); return; } else { if (StaticClass.GeneralClass.MD5Hash(pwbCurrentPassword.Password.Trim().ToString()) != StaticClass.GeneralClass.password_user_general) { tblNotification.Text = FindResource("current_password_incorrect").ToString(); pwbCurrentPassword.Focus(); return; } if (StaticClass.GeneralClass.MD5Hash(pwbNewPassword.Password.Trim().ToString()) != StaticClass.GeneralClass.MD5Hash(pwbConfirmPassword.Password.Trim().ToString())) { tblNotification.Text = FindResource("new_password_confirm_password_incorrect").ToString(); pwbConfirmPassword.Focus(); return; } else { EC_tb_User ec_tb_user = new EC_tb_User(); ec_tb_user.ID = StaticClass.GeneralClass.id_user_general; ec_tb_user.Password = StaticClass.GeneralClass.MD5Hash(pwbNewPassword.Password.Trim().ToString()); if (bus_tb_user.UpdatePasswordUser(ec_tb_user, StaticClass.GeneralClass.flag_database_type_general) == 1) { StaticClass.GeneralClass.password_user_general = ec_tb_user.Password; //return account page BBCodeBlock bbcodeblock = new BBCodeBlock(); bbcodeblock.LinkNavigator.Navigate(new Uri("/Pages/Setting/Account.xaml", UriKind.Relative), this); } } } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
private List <EC_tb_OrderDetail> GetOrderDetail(int orderid) { try { list_ec_tb_orderdetail.Clear(); dtgOrderDetail.Items.Refresh(); dt_tb_orderdetail.Clear(); int no = 0; dt_tb_orderdetail = bus_tb_orderdetail.GetOrderDetail("WHERE OrderID = " + orderid); foreach (DataRow datarow in dt_tb_orderdetail.Rows) { no++; EC_tb_OrderDetail ec_tb_orderdetail = new EC_tb_OrderDetail(); ec_tb_orderdetail.No = no; ec_tb_orderdetail.OrderID = Convert.ToInt32(datarow["OrderID"].ToString()); ec_tb_orderdetail.CategoryID = Convert.ToInt32(datarow["CategoryID"].ToString()); ec_tb_orderdetail.CategoryName = datarow["CategoryName"].ToString().Trim(); ec_tb_orderdetail.ProductID = Convert.ToInt32(datarow["ProductID"].ToString()); ec_tb_orderdetail.ProductName = datarow["ProductName"].ToString().Trim(); ec_tb_orderdetail.Cost = Convert.ToDecimal(datarow["Cost"].ToString()); ec_tb_orderdetail.StrCost = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_orderdetail.Cost); ec_tb_orderdetail.Price = Convert.ToDecimal(datarow["Price"].ToString()); ec_tb_orderdetail.StrPrice = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_orderdetail.Price); ec_tb_orderdetail.Qty = Convert.ToInt32(datarow["Qty"].ToString()); ec_tb_orderdetail.Tax = Convert.ToDecimal(datarow["Tax"].ToString()); ec_tb_orderdetail.StrTax = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_orderdetail.Tax); ec_tb_orderdetail.DiscountType = Convert.ToInt32(datarow["DiscountType"].ToString()); if (ec_tb_orderdetail.DiscountType == 1) { ec_tb_orderdetail.DisAmount = ""; ec_tb_orderdetail.DisPercent = "%"; } else { ec_tb_orderdetail.DisAmount = StaticClass.GeneralClass.currency_setting_general; ec_tb_orderdetail.DisPercent = ""; } ec_tb_orderdetail.Discount = Convert.ToDecimal(datarow["Discount"].ToString()); ec_tb_orderdetail.StrDiscount = StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_orderdetail.Discount); ec_tb_orderdetail.TotalDiscount = Convert.ToDecimal(string.IsNullOrEmpty(datarow["TotalDiscount"].ToString()) ? "0" : datarow["TotalDiscount"].ToString()); ec_tb_orderdetail.StrTotalDiscount = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_orderdetail.TotalDiscount); ec_tb_orderdetail.Total = Convert.ToDecimal(datarow["Total"].ToString()) + Convert.ToDecimal(datarow["Tax"].ToString()); ec_tb_orderdetail.StrTotal = StaticClass.GeneralClass.currency_setting_general + StaticClass.GeneralClass.GetNumFormatDisplay(ec_tb_orderdetail.Total); ec_tb_orderdetail.CheckDel = false; ec_tb_orderdetail.Currency = StaticClass.GeneralClass.currency_setting_general; list_ec_tb_orderdetail.Add(ec_tb_orderdetail); } tblTotal.Text = FindResource("total").ToString() + "(" + list_ec_tb_orderdetail.Count.ToString() + ")"; dtgOrderDetail.Items.Refresh(); } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } return(list_ec_tb_orderdetail); }
//btnLogin_Click private void btnLogin_Click(object sender, RoutedEventArgs e) { try { tblNotification.Text = ""; if (txbUsername.Text.Trim().ToString() == "") { tblNotification.Text = FindResource("username_null").ToString(); txbUsername.Focus(); return; } /*if (pwbPassword.Password.Trim() == "") * { * tblNotification.Text = FindResource("password_null").ToString(); * pwbPassword.Focus(); * return; * }*/ else { string _user_name = txbUsername.Text.Trim().ToString(); string user_name = _user_name.Substring(0, 1).ToUpper() + _user_name.Substring(1).ToLower(); string password = GeneralClass.MD5Hash(pwbPassword.Password.Trim().ToString()); bool _isLogin = false; thread_login = new Thread(() => { this.Dispatcher.Invoke((Action)(() => { mpr.IsActive = true; btnLogin.IsEnabled = false; })); DataTable dt_user = new DataTable(); dt_user = bus_tb_user.GetUser("WHERE [Name] = '" + user_name + "'"); if (dt_user.Rows.Count == 1) { if (string.IsNullOrEmpty(pwbPassword.Password.Trim().ToString()) && string.IsNullOrEmpty(dt_user.Rows[0]["Password"].ToString())) { _isLogin = true; } else if (dt_user.Rows[0]["Password"].ToString() == password || pwbPassword.Password.Trim().ToString() == dt_user.Rows[0]["Password"].ToString()) { _isLogin = true; } } if (_isLogin) { GeneralClass.user_permission = Convert.ToInt32(dt_user.Rows[0]["ID"].ToString()); GeneralClass.id_user_general = Convert.ToInt32(dt_user.Rows[0]["ID"].ToString()); GeneralClass.name_user_general = user_name; GeneralClass.password_user_general = dt_user.Rows[0]["Password"].ToString(); this.Dispatcher.Invoke((Action)(() => { app.mainWindow.TitleLinks.Remove(app.linkLogin); app.mainWindow.TitleLinks.Add(app.linkAccount); app.linkAccount.DisplayName = Application.Current.FindResource("hi").ToString() + " " + GeneralClass.name_user_general; app.mainWindow.TitleLinks.Add(app.linkLogout); app.mainWindow.MenuLinkGroups.Remove(app.linkGroupLogInOut); app.mainWindow.MenuLinkGroups.Remove(app.linkGroupOption); })); switch (GeneralClass.user_permission) { case (int)GeneralClass.UserPermission.admin: //admin permission this.Dispatcher.Invoke((Action)(() => { app.mainWindow.MenuLinkGroups.Add(app.linkGroupReport); app.mainWindow.MenuLinkGroups.Add(app.linkGroupSetting); app.mainWindow.MenuLinkGroups.Add(app.linkGroupChart); app.mainWindow.MenuLinkGroups.Add(app.linkGroupStatistic); })); break; case (int)GeneralClass.UserPermission.inventory: //inventory permission this.Dispatcher.Invoke((Action)(() => { app.mainWindow.MenuLinkGroups.Add(app.linkGroupSetting); })); break; case (int)GeneralClass.UserPermission.report: //report permission this.Dispatcher.Invoke((Action)(() => { app.mainWindow.MenuLinkGroups.Add(app.linkGroupReport); })); break; default: break; } this.Dispatcher.Invoke((Action)(() => { app.mainWindow.MenuLinkGroups.Add(app.linkGroupOption); app.mainWindow.MenuLinkGroups.Add(app.linkGroupLogInOut); })); //save logs if (StaticClass.GeneralClass.app_settings["isSaveLogs"].ToString() == "True") { new System.Threading.Thread(() => { GeneralClass.SaveLogs(user_name, "Logged in", DateTime.Now); }).Start(); } this.Dispatcher.Invoke((Action)(() => { app.mainWindow.ContentSource = new Uri(@"/Pages/Home/Home.xaml", UriKind.Relative); })); _isLogin = false; } else { this.Dispatcher.Invoke((Action)(() => { mpr.IsActive = false; tblNotification.Text = FindResource("username_password_incorrect").ToString(); btnLogin.IsEnabled = true; txbUsername.Focus(); })); } }); thread_login.Start(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
private void muiBtnPrint_Click(object sender, RoutedEventArgs e) { try { if (order_thread != null && order_thread.ThreadState == ThreadState.Running) { order_thread.Abort(); return; } else { order_thread = new Thread(() => { this.muiBtnPrint.Dispatcher.Invoke((Action)(() => { muiBtnPrint.Visibility = System.Windows.Visibility.Hidden; })); this.mprPrint.Dispatcher.Invoke((Action)(() => { mprPrint.IsActive = true; })); ReportDetailPrint page = new ReportDetailPrint(); page.titleParameter = FindResource("list_of_order").ToString(); page.idParameter = FindResource("id").ToString(); page.categoryNameParameter = FindResource("category_name").ToString(); page.productIDParameter = FindResource("product_id").ToString(); page.productNameParameter = FindResource("product_name").ToString(); page.priceParameter = FindResource("price").ToString(); page.qtyParameter = FindResource("qty").ToString(); page.taxParameter = FindResource("tax").ToString(); page.discountTypeParameter = FindResource("discount_type").ToString(); page.discountParameter = FindResource("discount").ToString(); page.totalParameter = FindResource("total").ToString(); this.Dispatcher.Invoke((Action)(() => { var m = Application.Current.MainWindow; Point m_point_to_screen = StaticClass.GeneralClass.ElementPointToScreenPoint(m as UIElement, new Point(0, 0)); if (m.RenderSize.Width > StaticClass.GeneralClass.width_screen_general) { page.point_x = (int)(m_point_to_screen.X + StaticClass.GeneralClass.width_screen_general / 2 - page.Width / 2); page.Height = (int)m.RenderSize.Height; } if (m.RenderSize.Height > StaticClass.GeneralClass.height_screen_working_general) { page.point_y = 0; page.Height = (int)StaticClass.GeneralClass.height_screen_working_general; } else { page.point_x = (int)(m_point_to_screen.X + (m.RenderSize.Width / 2 - page.Width / 2)); page.point_y = (int)m_point_to_screen.Y; page.Height = (int)m.RenderSize.Height; } page.ShowInTaskbar = false; })); Thread.Sleep(500); this.mprPrint.Dispatcher.Invoke((Action)(() => { mprPrint.IsActive = false; })); this.muiBtnPrint.Dispatcher.Invoke((Action)(() => { muiBtnPrint.Visibility = System.Windows.Visibility.Visible; })); page.ShowDialog(); }); order_thread.SetApartmentState(ApartmentState.STA); order_thread.Start(); } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }
//Paycash private void Paycash(string num, bool isenable) { try { if (!flagStandardCal) { flagStandardCal = true; tblPayCash.Text = "0"; } btnEnter.IsEnabled = isenable; btnSaveInvoice.IsEnabled = false; btnSaveSendEmail.IsEnabled = false; this.tblCashBalance.Text = "00.00"; if (num == "." || num == ",") { if (tblPayCash.Text.Trim().Contains(".") || tblPayCash.Text.Trim().Contains(",")) { return; } } btntemp.Focus(); string strTemp = ""; strTemp = tblPayCash.Text.Trim(); if (strTemp.Length == 1) { if (strTemp == "0") { if (num == "0") { tblPayCash.Text = "0"; } if (num == "." || num == ",") { tblPayCash.Text += num; } else { tblPayCash.Text = num; } } else { tblPayCash.Text += num; } } else { string checkPoint = ""; checkPoint = strTemp.Substring(strTemp.Length - 1, 1); if ((checkPoint == "." && num == ".") || (checkPoint == "," && num == ",")) { tblPayCash.Text = strTemp; } else { tblPayCash.Text += num; } } } catch (Exception ex) { Pages.Notification page = new Pages.Notification(); page.tblNotification.Text = ex.Message; page.ShowDialog(); } }