public Login() { try { InitializeComponent(); //string connString = ModuleClass.Connect(); //DataAccess.RedaV1Entities db = ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect()); db = ModuleClass.GetConnection(); DevExpress.UserSkins.BonusSkins.Register(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); AssemblyTitleAttribute assembly = executingAssembly.GetCustomAttribute <AssemblyTitleAttribute>(); AssemblyFileVersionAttribute assemblyVersion = executingAssembly.GetCustomAttribute <AssemblyFileVersionAttribute>(); this.Text = assembly.Title + " " + assemblyVersion.Version;// +" ( " + UserData.Default.UserName + " ) ";// +branch.BranchName; SkinContainerCollection skins = SkinManager.Default.Skins; for (int i = 0; i < skins.Count; i++) { cmbTheme.Properties.Items.Add(skins[i].SkinName); } LoadData(); } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
private void btnGetAll_Click(object sender, EventArgs e) { try { int bId = 0; if (rbReda1.Checked) { bId = 1; } else { bId = 2; } DateTime from = new DateTime(cmbFrom.DateTime.Year, cmbFrom.DateTime.Month, cmbFrom.DateTime.Day, 0, 0, 0); DateTime to = new DateTime(cmbTo.DateTime.Year, cmbTo.DateTime.Month, cmbTo.DateTime.Day, 23, 59, 59); db = new DataAccess.RedaV1Entities(ModuleClass.Connect()); var list = db.PurchaseInvoices.Where(s => s.BranchID == bId && s.Date >= from && s.Date <= to).ToList(); bindingSource1.DataSource = list; } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
private void txtSearch_KeyDown(object sender, KeyEventArgs e) { try { string query = txtSearch.Text; if (e.KeyCode == Keys.Enter) { db = new DataAccess.RedaV1Entities(ModuleClass.Connect()); if (!chHidden.Checked) { db.Items.Where(s => s.Name.Contains(query) && s.Hidden == false).Load(); var list = db.Items.Local.ToBindingList(); bindingSource1.DataSource = list; } else { db.Items.Where(s => s.Name.Contains(query)).Load(); var list = db.Items.Local.ToBindingList(); bindingSource1.DataSource = list; } } } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
void GetInvoices() { try { if (rbSearchByDate.Checked) { DateTime from = new DateTime(cmbFrom.DateTime.Year, cmbFrom.DateTime.Month, cmbFrom.DateTime.Day, 0, 0, 0); DateTime to = new DateTime(cmbTo.DateTime.Year, cmbTo.DateTime.Month, cmbTo.DateTime.Day, 23, 59, 59); db = new DataAccess.RedaV1Entities(ModuleClass.Connect()); var list = db.PurchaseInvoices.Where(s => s.BranchID == branchID && s.Date >= from && s.Date <= to).ToList(); bindingSource1.DataSource = list; } else { string query = txtSearch.Text; db = new DataAccess.RedaV1Entities(ModuleClass.Connect()); db.PurchaseInvoices.Where(s => s.Number.Contains(query)).Load(); var list = db.PurchaseInvoices.Local.ToBindingList(); bindingSource1.DataSource = list; } } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
public Settings(DataAccess.RedaV1Entities db) { InitializeComponent(); this.db = db; userBindingSource.DataSource = this.db.Users.Where(s => s.IsEnable == true).ToList();//.Where(s => s.IsAdmin == true) companyBindingSource.DataSource = this.db.Companies.Take(1).SingleOrDefault(); messageTypeBindingSource.DataSource = this.db.MessageTypes.ToList(); }
private void btnAddUser_Click(object sender, EventArgs e) { try { if (!dxErrorProvider1.HasErrors) { int userId = Convert.ToInt32(cmbUserName.EditValue); int year = DateTime.Now.Year; int month = DateTime.Now.Month; int day = DateTime.Now.Day; string password = txtPassword.EditValue.ToString().ToLower(); var ValidUser = db.Users.Where(s => s.ID == userId && s.Password.ToLower() == password).SingleOrDefault(); var _shift = db.Shifts.Where(s => s.ID == ModuleClass.shiftID).SingleOrDefault(); if (ValidUser != null) { if (_shift.ShiftUsers.Where(s => s.UserID == userId).Any()) { MessageBox.Show(" للوردية " + cmbUserName.Text + " لا يمكن إضافة المسخدم ", "المستخدم موجود بالوردية"); return; } DataAccess.ShiftUser shiftUser = db.ShiftUsers.Create(); shiftUser.ShiftID = _shift.ID; shiftUser.UserID = userId; shiftUser.LogInTime = DateTime.Now; shiftUser.LogoutTime = DateTime.Now; shiftUser.Duration = 0; shiftUser.Flag = 0; _shift.ShiftUsers.Add(shiftUser); if (db.SaveChanges() > 0) { var message = "" + UserData.Default.BranchName + " فرع " + " للوردية " + cmbUserName.Text + " تمت إضافة المستخدم "; PushMessage.SendSignOnMessage(message); MessageBox.Show(message); Thread.Sleep(1500); this.Close(); } } else { MessageBox.Show("الرجاء التأكد من اسم المستخدم وكلمة المرور"); } } } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); db = ModuleClass.GetConnection(); } }
DataAccess.RedaV1Entities db = null;// public PushOverUC() { try { InitializeComponent(); db = ModuleClass.GetConnection(); branchBindingSource.DataSource = db.Branches.ToList(); } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
private void btnShowHidden_Click(object sender, EventArgs e) { try { db = new DataAccess.RedaV1Entities(ModuleClass.Connect()); db.Items.Where(s => s.Hidden == true).Load(); var list = db.Items.Local.ToBindingList(); bindingSource1.DataSource = list; } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
public SaleInvoiceConfirm(List <DataAccess.vw_Sale2> rptList, BindingList <DataAccess.SaleInvoiceDetail> details, DataAccess.RedaV1Entities db, string InvoicePrinter) { InitializeComponent(); this.details = details; this.db = db; this.rptList = rptList; foreach (var item in details) { invoiceTotal += (item.UnitPrice * item.Quanitity); } txtInvoiceTotal.EditValue = invoiceTotal; branchID = Convert.ToInt32(UserData.Default.BranchID); this.InvoicePrinter = InvoicePrinter; dicountAllowed = db.Companies.Take(1).SingleOrDefault().DiscountValue; }
private void btnAddUser_Click(object sender, EventArgs e) { try { if (!dxErrorProvider1.HasErrors) { DataAccess.Request request = db.Requests.Create(); itemID = 0; userID = Convert.ToInt32(UserData.Default.UserID); string UserName = Convert.ToString(UserData.Default.UserName); branchID = Convert.ToInt32(UserData.Default.BranchID); quantity = Convert.ToInt32(txtQuantity.EditValue); string desciption = txtDescription.Text; request.UserID = userID; request.BranchID = branchID; request.RequestDate = DateTime.Now; request.Quantity = quantity; request.Description = desciption; var itemObj = (ItemObject)listBoxControl1.SelectedItem; request.ItemID = Convert.ToInt32(itemObj.Data); db.Requests.Add(request); if (db.SaveChanges() > 0) { #if !DEBUG var message = "" + UserData.Default.BranchName + " فرع " + UserName + " من المستخدم " + lblItem.Text + " تمت طلب الصنف "; PushMessage.SendDirectMessage(message); #endif MessageBox.Show("تم حفظ الطلب و إرساله للإدارة", "شكرا لاهتمامك"); // Thread.Sleep(1500); // this.Close(); } else { MessageBox.Show("توجد مشكلة في حفظ البيانات، الرجاء المحاولة مرة أخري"); } } } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); db = ModuleClass.GetConnection(); } }
private void txtSearch_KeyDown(object sender, KeyEventArgs e) { try { string query = txtSearch.Text; if (e.KeyCode == Keys.Enter) { db = new DataAccess.RedaV1Entities(ModuleClass.Connect()); db.PurchaseInvoices.Where(s => s.Number.Contains(query)).Load(); var list = db.PurchaseInvoices.Local.ToBindingList(); bindingSource1.DataSource = list; } } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
private void btnGetAll_Click(object sender, EventArgs e) { try { db = new DataAccess.RedaV1Entities(ModuleClass.Connect()); bindingSourceUsers.DataSource = db.Users.Where(s => s.IsEnable == true).ToList(); // db.Items.Local.Clear(); // var list = new ObservableCollection(db.ItemCategories.ToList()); //db.Configuration.LazyLoadingEnabled = false; // db.Items.Where(s => s.ID > 8); db.SaleInvoices.Load(); /// db.Items.Local.AsLive().OrderBy(x => x.Id); var list = db.SaleInvoices.Local.ToBindingList(); bindingSourceSaleInvoice.DataSource = list; } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
private void xrTableCell14_PreviewDoubleClick(object sender, PreviewMouseEventArgs e) { DataAccess.RedaV1Entities db = WinForm.ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect()); int invoiceID = Convert.ToInt32(e.Brick.Text); var currentRow = db.vw_SaleReport.Where(s => s.ID == invoiceID).SingleOrDefault(); //(DataAccess.vw_SaleReport)gridViewSaleInvoice.GetFocusedRow(); SaleAllRpt rpt = new SaleAllRpt(Convert.ToDecimal(currentRow.Discount), Convert.ToDecimal(currentRow.Total), currentRow.ID.ToString(), currentRow.UserName.ToString()); var list = from s in db.vw_Sale2 where s.SaleInvoiceID == invoiceID select s; rpt.DataSource = list.ToList(); try { ReportPrintTool tool = new ReportPrintTool(rpt); tool.ShowPreview(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public RequestItem() { try { InitializeComponent(); //string connString = ModuleClass.Connect(); //DataAccess.RedaV1Entities db = ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect()); db = ModuleClass.GetConnection(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); AssemblyTitleAttribute assembly = executingAssembly.GetCustomAttribute <AssemblyTitleAttribute>(); AssemblyFileVersionAttribute assemblyVersion = executingAssembly.GetCustomAttribute <AssemblyFileVersionAttribute>(); /* * DataTable dt = new DataTable(); * dt.Columns.Add("ID", typeof(int)); * dt.Columns.Add("Name", typeof(string)); * * cmbSearch.Properties.DataSource = dt; * cmbSearch.Properties.ValueMember = "ID"; * cmbSearch.Properties.DisplayMember = "Name"; */ //cmbSearch.Properties.ValueMember = "ID"; // cmbSearch.Properties.DisplayMember = "Value"; //cmbSearch.Properties.PopupFilterMode = PopupFilterMode.Contains // myLookUpEdit1.Properties.PopulateColumns(); // myLookUpEdit1.Properties.Columns[0].Visible = false; //this.myLookUpEdit1.Properties.PopulateColumns(); db.Items.Load(); //LoadData(); } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
public AddLogin() { try { InitializeComponent(); //string connString = ModuleClass.Connect(); //DataAccess.RedaV1Entities db = ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect()); db = ModuleClass.GetConnection(); DevExpress.UserSkins.BonusSkins.Register(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); AssemblyTitleAttribute assembly = executingAssembly.GetCustomAttribute <AssemblyTitleAttribute>(); AssemblyFileVersionAttribute assemblyVersion = executingAssembly.GetCustomAttribute <AssemblyFileVersionAttribute>(); this.Text = assembly.Title + " " + assemblyVersion.Version;// +" ( " + UserData.Default.UserName + " ) ";// +branch.BranchName; //LoadData(); } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
public AddUserToShift() { try { InitializeComponent(); //string connString = ModuleClass.Connect(); //DataAccess.RedaV1Entities db = ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect()); db = ModuleClass.GetConnection(); DevExpress.UserSkins.BonusSkins.Register(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); AssemblyTitleAttribute assembly = executingAssembly.GetCustomAttribute <AssemblyTitleAttribute>(); AssemblyFileVersionAttribute assemblyVersion = executingAssembly.GetCustomAttribute <AssemblyFileVersionAttribute>(); LoadData(); } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); } }
DataAccess.RedaV1Entities db;// = new DataAccess.RedaV1Entities(ModuleClass.Connect()); public DamegeUC(DataAccess.RedaV1Entities db) { this.db = db; InitializeComponent(); }
public DollarRateForm() { InitializeComponent(); db = ModuleClass.GetConnection(); fillGrid(); }
private void btnNumberOfhoursToUser_Click(object sender, EventArgs e) { try { dxErrorProvider1.ClearErrors(); if (cmbUserName.EditValue == null) { dxErrorProvider1.SetError(cmbUserName, "يجد تحديد الموظف "); } if (txtHourNumbers.EditValue == "") { dxErrorProvider1.SetError(txtHourNumbers, "يجد تحديد عدد الساعات للموظف"); } if (txtDescription.Text == string.Empty || txtDescription.Text == "" || txtDescription.Text == null || txtDescription.Text.Length < 7) { dxErrorProvider1.SetError(txtDescription, "يجد تحديد الغرض بصورة واضحة"); } if (!dxErrorProvider1.HasErrors) { int userId = Convert.ToInt32(cmbUserName.EditValue); int year = DateTime.Now.Year; int month = DateTime.Now.Month; int day = DateTime.Now.Day; var message = " تمت إضافة زمن للمستخدم " + cmbUserName.Text + " لمدة " + txtHourNumbers.Text + " ساعات "; message += " الغرض "; message += txtDescription.Text; string NumberOfhours = txtHourNumbers.EditValue.ToString().ToLower(); decimal balance = db.UserPayments.Where(s => s.UserID == userId).Select(s => (decimal?)s.Amount).Sum() ?? 0; //(SELECT SUM(Amount) FROM[dbo].[UserPayment] Where UserID = @UserID) decimal hourRate = Convert.ToDecimal(cmbUserName.GetColumnValue("HourRate")); var _userPayment = new DataAccess.UserPayment(); _userPayment.Amount = Convert.ToDecimal(NumberOfhours) * hourRate; _userPayment.Balance = balance + _userPayment.Amount; _userPayment.Date = DateTime.Now; _userPayment.Desciption = message; _userPayment.InvoiceID = 0; _userPayment.PaymentType = 1; _userPayment.UserID = userId; db.UserPayments.Add(_userPayment); /* * var _shift = db.Shifts.Where(s => s.BranchID == 1).OrderBy(s => s.ID).First();// .LastOrDefault();//.SingleOrDefault(); * DataAccess.ShiftUser newShift = new DataAccess.ShiftUser(); * newShift.Duration = Convert.ToDecimal(NumberOfhours) * 60; * newShift.ShiftID = _shift.ID; * newShift.LogInTime = DateTime.Now.AddHours(-1 * Convert.ToDouble(NumberOfhours)); * newShift.LogoutTime = DateTime.Now; * newShift.UserID = userId; * newShift.Flag = 1; * db.ShiftUsers.Add(newShift); */ if (db.SaveChanges() > 0) { if (cmbUserName.GetColumnValue("PushoverID") != null) { string pushid = cmbUserName.GetColumnValue("PushoverID").ToString(); List <string> userIDs = new List <string>(); userIDs.Add(pushid); var userPayment = db.UserPayments.Where(s => s.UserID == userId).OrderByDescending(s => s.ID).Take(1).SingleOrDefault(); var amount = userPayment.Amount; balance = userPayment.Balance; message += Environment.NewLine + " " + "القيمة " + amount + Environment.NewLine + " " + " المطالبة الحالية: " + balance + Environment.NewLine; PushMessage.SendUserPaymentStatusMessage(message, userIDs); MessageBox.Show(message); Thread.Sleep(1500); } this.Close(); } } } catch (Exception ex) { ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null); db = ModuleClass.GetConnection(); } }