Ejemplo n.º 1
0
        public static bool SendDailyInventoryStatus(int branchID, DateTime dateFrom, DateTime toFrom)
        {
            try {
                DateTime from = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day, 0, 0, 0);
                DateTime to   = new DateTime(toFrom.Year, toFrom.Month, toFrom.Day, 23, 59, 59);
                var      db   = ModuleClass.GetConnection();
                var      list = db.vw_ReorderItem.Where(s => s.Date > from && s.Date < to && s.BranchID == branchID && s.CurrentQuanity <= s.ReorderPoint && s.CategoryID != 2013).ToList();
                if (list.Count() == 0)
                {
                    return(true);
                }
                string message = " ----  ملخص كميات الأصناف رضا" + branchID + " -----" + Environment.NewLine;
                foreach (var item in list)
                {
                    message += item.Name + " " + item.CurrentQuanity + Environment.NewLine;
                }


                int codeId    = (int)PushOverMessageType.DailyInventoryStatus;
                var receivers = GetReceiver(codeId);
                var title     = GetTitle(codeId);
                return(SendPushMessage(message, receivers, title));
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        public static bool SendItemWithoutBarcode(int branchID, DateTime dateFrom, DateTime toFrom)
        {
            try
            {
                DateTime from = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day, 0, 0, 0);
                DateTime to   = new DateTime(toFrom.Year, toFrom.Month, toFrom.Day, 23, 59, 59);
                var      db   = ModuleClass.GetConnection();
                var      list = db.vw_ReorderItem.Where(s => s.Date > from && s.Date < to && s.BranchID == branchID && s.Remarks != null && s.CategoryID != 2013).ToList();
                if (list.Count() == 0)
                {
                    return(true);
                }
                string message = "   ملخص  الأصناف بدون باركود رضا" + branchID + " " + Environment.NewLine;
                foreach (var item in list)
                {
                    message += item.Name + " " + item.Remarks + " " + item.UserName + Environment.NewLine;
                }


                int codeId    = (int)PushOverMessageType.ItemWithoutBarcode;
                var receivers = GetReceiver(codeId);
                var title     = GetTitle(codeId);
                return(SendPushMessage(message, receivers, title));
            }
            catch (Exception ex)
            {
                return(false);
            }

            //return PushMessage.SendPushMessage(message, title);
        }
Ejemplo n.º 4
0
        private void btnShowFullReport_Click(object sender, EventArgs e)
        {
            try
            {
                DataAccess.RedaV1Entities db = ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect());
                int invoiceID = 123;

                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
                {
                    //  string InvoicePrinter = System.Configuration.ConfigurationManager.AppSettings["InvoicePrinter"];
                    ReportPrintTool tool = new ReportPrintTool(rpt);
                    tool.ShowPreview();
                }
                catch (Exception ex)
                {
                    ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
                }
            }
            catch (Exception ex)
            {
                ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
            }
        }
Ejemplo n.º 5
0
        static List <string> GetReceiver(int CodeID)
        {
            List <string> receivers;
            var           db = ModuleClass.GetConnection();

            receivers = db.vw_PushoverMessage.Local.Where(s => s.CodeID == CodeID && s.EnableMessage == true && s.PushoverID != null).Select(s => s.PushoverID).ToList();
            return(receivers);
        }
Ejemplo n.º 6
0
        bool SendWhatsAppMessage(String receiver, String Message)
        {
            bool result = false;

            try
            {
                //Send ( button_click )

                DataAccess.RedaV1Entities db      = ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect());
                DataAccess.Company        company = db.Companies.Take(1).SingleOrDefault();

                string WhatsAppCode   = company.WhatsAppCode;   // UserData.Default.WhatsAppCode;
                string WhatsAppSender = company.WhatsAppSender; // UserData.Default.WhatsAppSender;



                string from = WhatsAppSender;
                string to   = receiver;
                string msg  = Message;

                WhatsApp wa = new WhatsApp(from, WhatsAppCode, "RedaPos", false, true);

                wa.OnConnectSuccess += () =>
                {
                    //   MessageBox.Show("Connected to whatsapp...");

                    wa.OnLoginSuccess += (phoneNumber, data) =>
                    {
                        wa.SendMessage(to, msg);
                        result = true;
                    };

                    wa.OnLoginFailed += (data) =>
                    {
                        MessageBox.Show("Login Failed : {0}", data);
                        result = false;
                    };

                    wa.Login();
                };

                wa.OnConnectFailed += (ex) =>
                {
                    MessageBox.Show("Connection Failed...");
                    result = false;
                };

                wa.Connect();
            }
            catch (Exception ex2)
            {
                result = false;
            }

            return(result);
        }
Ejemplo n.º 7
0
        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();
            }
        }
Ejemplo n.º 8
0
 DataAccess.RedaV1Entities db = null;//
 public PushOverUC()
 {
     try
     {
         InitializeComponent();
         db = ModuleClass.GetConnection();
         branchBindingSource.DataSource = db.Branches.ToList();
     }
     catch (Exception ex)
     {
         ModuleClass.ShowExceptionMessage(this, ex, "خطأ", null);
     }
 }
Ejemplo n.º 9
0
        static string  GetTitle(int CodeID)
        {
            try
            {
                var db = ModuleClass.GetConnection();

                string title = db.MessageTypes.Local.Where(s => s.CodeID == CodeID).Select(s => s.Message).SingleOrDefault().ToString();
                return(title);
            }
            catch (Exception ex)
            {
                return("");
            }
        }
Ejemplo n.º 10
0
        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();
            }
        }
Ejemplo n.º 11
0
        public static bool SendPriceChangeMessage(String Message)
        {
            try
            {
                bool result = true;

                var db     = ModuleClass.GetConnection();
                int codeId = (int)PushOverMessageType.PriceChange;

                var receivers = GetReceiver(codeId);
                var title     = GetTitle(codeId);

                result = SendPushMessage(Message, receivers, title);

                return(result);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
        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);
            }
        }
Ejemplo n.º 14
0
        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);
            }
        }
Ejemplo n.º 15
0
        public static bool SendSignOutMessage(String Message)
        {
            try
            {
                bool result = true;

                var db     = ModuleClass.GetConnection();
                int codeId = (int)PushOverMessageType.SignOut;

                var receivers = GetReceiver(codeId);
                var title     = GetTitle(codeId);
                //var message = db.MessageTypes.Local.Where(s => s.CodeID == codeId).Select(s => s.Template).SingleOrDefault().ToString();

                // message = String.Format(message, Branch, date.ToString(), user);

                result = SendPushMessage(Message, receivers, title);

                return(result);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 16
0
 public DollarRateForm()
 {
     InitializeComponent();
     db = ModuleClass.GetConnection();
     fillGrid();
 }
Ejemplo n.º 17
0
        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();
            }
        }