Esempio n. 1
0
        protected void gvSer_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(gvSer.Rows[e.RowIndex].Cells[7].Text);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                // check that the service is not attached
                var att = club.InvoiceServices.Where(a => a.ServiceID == id).FirstOrDefault();
                var re  = club.Services.Where(a => a.ServiceID == id).First();
                if (att == null)
                {
                    club.Services.DeleteObject(re);
                    club.SaveChanges();
                }
                else
                {
                    re.Deleted = true;
                    club.SaveChanges();
                }

                gvSer.DataSource = club.getServices();
                gvSer.DataBind();
                string Message = " تم الحذف  ";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);
            }
        }
Esempio n. 2
0
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            string toPerson = tbTo.Text;

            decimal amount  = Convert.ToDecimal(tbAmount.Text);
            string  amountW = tbAmountW.Text;
            string  note    = tbNotes.Text;
            long?   check   = null;
            string  bank    = "";

            if (pnlBank.Visible)
            {
                check = Convert.ToInt64(tbCheck.Text);
                bank  = tbBank.Text;
            }
            using (ClubDBEntities club = new ClubDBEntities())
            {
                string username = User.Identity.Name;
                var    emp      = (from o in club.Employees
                                   where o.UserName == username
                                   select o).First();
                Deposit deposit = new Deposit();
                deposit.Amount     = amount;
                deposit.AmountW    = amountW;
                deposit.Bank       = bank;
                deposit.CheckNum   = check;
                deposit.Date       = Convert.ToDateTime(tbDate.Text);
                deposit.Notes      = note;
                deposit.Employee   = toPerson;
                deposit.FromPerson = tbFrom.Text;
                deposit.InvID      = invID;
                club.Deposits.AddObject(deposit);
                club.SaveChanges();
                // update invoice services
                var servises = from s in club.InvoiceServices
                               where s.InvID == invID
                               select s;
                if (servises.Count() != 0)
                {
                    foreach (var row in servises)
                    {
                        row.PaidAmount += amount * Convert.ToDecimal(row.Percentage);
                    }
                }
                club.SaveChanges();

                // print the bill
                Response.Redirect("ReportViewer.aspx?type=1&id=" + deposit.ID);
                //var result = club.getDepositReport(deposit.ID);
                //DepositCR report = new DepositCR();
                //report.Load(Server.MapPath("DepositCR.rpt"));
                //report.SetDataSource(result);
                //string printer = "";
                //report.PrintOptions.PrinterName = ClubWebApp.Properties.Settings.Default.InvoicePrinter;
                //report.PrintOptions.PrinterName = printer;
                //report.PrintToPrinter(1, false, 0, 0);
            }
            //Response.Redirect("Default.aspx");
        }
Esempio n. 3
0
        private void updateInvoice(int invoiceID)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                InvoiceHeader result = (from o in club.InvoiceHeaders
                                        where o.InvID == invoiceID
                                        select o).First();
                decimal total = Convert.ToDecimal(tbTotal.Text);
                int     dis   = (string.IsNullOrEmpty(tbDis.Text)) ? 0 : Convert.ToInt32(tbDis.Text);
                decimal final = Convert.ToDecimal(tbFinal.Text);
                //decimal paid = Convert.ToDecimal(tbPaid.Text);
                //decimal rem = string.IsNullOrEmpty(tbRemain.Text) ? 0 : Convert.ToDecimal(tbRemain.Text);
                result.TotalAmount = total;
                result.Discount    = dis;
                result.FinalAmount = final;
                // result.PaidAmount = paid;
                // result.RemainAmount = rem;
                result.Notes  = tbNotes.Text;
                result.Status = InvoiceStatus.Complete.ToString();
                result.Type   = rbType.SelectedValue;
                club.SaveChanges();
                // create deposit
                Deposit deposit = new Deposit();
                deposit.InvID      = invoiceID;
                deposit.Notes      = tbNotes.Text;
                deposit.Date       = DateTime.Now.Date;
                deposit.Employee   = club.Employees.Where(a => a.UserName == User.Identity.Name).Select(o => o.Name).First();
                deposit.FromPerson = club.Clients.Where(a => a.ClientID == result.ClientID).First().FullName();

                switch (rbType.SelectedIndex)
                {
                case 0:
                    deposit.CheckNum = Convert.ToInt64(tbCheck.Text);
                    deposit.Bank     = tbBank.Text;

                    break;

                case 1:
                    decimal paid = Convert.ToDecimal(tbPaid.Text);
                    deposit.Amount = paid;

                    break;

                case 2:
                    decimal amount = Convert.ToDecimal(tbFinal.Text);
                    deposit.Amount = amount;
                    break;
                }
                club.Deposits.AddObject(deposit);
                club.SaveChanges();
                VoucherID = deposit.ID;
                InvID     = invoiceID;
            }
        }
Esempio n. 4
0
        protected void gvSubs_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            lblError.Visible = false;
            int id = Convert.ToInt32(gvSubs.Rows[e.RowIndex].Cells[5].Text);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                var intsub = club.IntSubs.Where(a => a.SubID == id).FirstOrDefault();
                var nutsub = club.NutSubs.Where(a => a.SubID == id).FirstOrDefault();
                var sub    = club.Subscribtions.Where(a => a.SubID == id).First();
                if (intsub != null)
                {
                    club.IntSubs.DeleteObject(intsub);
                }
                if (nutsub != null)
                {
                    club.NutSubs.DeleteObject(nutsub);
                }
                club.Subscribtions.DeleteObject(sub);
                try
                {
                    club.SaveChanges();
                    string Message = " تم حذف الاشتراك  ";
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);
                    FillSubData();
                }
                catch
                {
                    lblError.Text    = "لايمكن حذف الاشتراك لوجود زيارات متعلقة";
                    lblError.Visible = true;
                }
            }
        }
Esempio n. 5
0
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            string role = ddlRoles.SelectedValue;

            Roles.AddUserToRole(RegisterUser.UserName, role);

            //DropDownList ddlname = (DropDownList)RegisterUserWizardStep.ContentTemplateContainer.FindControl("ddlName");
            TextBox tbU = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("UserName");

            if ((tbU != null))
            {
                string username = tbU.Text;
                empID = Convert.ToInt32(ddlName.SelectedValue);
                using (ClubDBEntities club = new ClubDBEntities())
                {
                    var emp = (from o in club.Employees
                               where o.EmpID == empID
                               select o).First();
                    emp.UserName = username;
                    club.SaveChanges();
                }
            }
            //Response.Redirect("Default.aspx");
            //FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);

            //string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            //if (String.IsNullOrEmpty(continueUrl))
            //{
            //    continueUrl = "~/";
            //}
            //Response.Redirect(continueUrl);
        }
        private void Save()
        {
            DateTime date = Convert.ToDateTime(tbDate.Text, cul);
            int      id   = Convert.ToInt32(tbID.Text);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                // get employee
                string name  = User.Identity.Name;
                int    empID = (from o in club.Employees
                                where o.UserName == name
                                select o.EmpID).First();

                Evaluation eval = new Evaluation();
                eval.ClientID   = id;
                eval.EmployeeID = empID;
                eval.Assessment = tbAssess.Text;
                eval.Date       = date;
                eval.Diagnosis  = tbDia.Text;
                eval.Goals      = tbGoals.Text;
                eval.History    = tbHistory.Text;
                eval.Objective  = tbObjective.Text;
                eval.Treatment  = tbTreat.Text;
                club.Evaluations.AddObject(eval);
                club.SaveChanges();
                EID   = eval.ID;
                saved = true;
            }
        }
Esempio n. 7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ClubDBEntities club = new ClubDBEntities();

            long?id = null;
            int? i  = null;

            Client client = new Client()
            {
                FirstName    = tbFirstName.Text,
                SecondName   = tbSecondName.Text,
                LastName     = tbLastName.Text,
                FamilyName   = tbFamilyName.Text,
                DOB          = string.IsNullOrEmpty(tbDOB.Text) ? i : Convert.ToInt32(tbDOB.Text),
                Nationality  = tbNation.Text,
                IDNumber     = string.IsNullOrEmpty(tbID.Text) ? id : Convert.ToInt64(tbID.Text),
                Phone        = string.IsNullOrEmpty(tbPhone.Text) ? id : Convert.ToInt64(tbPhone.Text),
                Marital      = rbMarital.SelectedValue,
                RefferedFrom = tbRefferedFrom.Text,
                RefferedDate = DateTime.Now.Date,
                Status       = Status.Inactive.toString()
            };

            club.AddToClients(client);
            club.SaveChanges();
            //string Message = " تمت اضافة العضوة  ";
            //ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);

            Response.Redirect("Invoice.aspx?New=" + client.ClientID);
        }
Esempio n. 8
0
 protected void gvEmp_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         int id = Convert.ToInt32(gvEmp.Rows[e.RowIndex].Cells[5].Text);
         using (ClubDBEntities club = new ClubDBEntities())
         {
             var emp = club.Employees.Where(a => a.EmpID == id).First();
             club.Employees.DeleteObject(emp);
             if (!string.IsNullOrEmpty(emp.UserName))
             {
                 Membership.DeleteUser(emp.UserName, true);
             }
             club.SaveChanges();
             gvEmp.DataSource = club.getEmployees();
             gvEmp.DataBind();
             string Message = " تم الحذف  ";
             ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);
         }
     }
     catch
     {
         lblError.Text    = "لايمكن حذف الموظف";
         lblError.Visible = true;
     }
 }
        private void Save()
        {
            DateTime date = Convert.ToDateTime(tbDate.Text, cul).Date;
            int      id   = Convert.ToInt32(tbID.Text);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                // get employee
                string name  = User.Identity.Name;
                int    empID = (from o in club.Employees
                                where o.UserName == name
                                select o.EmpID).First();

                Discharge eval = new Discharge();
                eval.ClientID       = id;
                eval.EmployeeID     = empID;
                eval.Date           = date;
                eval.Diagnosis      = tbDia.Text;
                eval.Goals          = tbGoals.Text;
                eval.Treatment      = tbTreat.Text;
                eval.PreReferral    = tbPreReferrals.Text;
                eval.InitialSession = Convert.ToDateTime(tbInitialSession.Text, cul);
                eval.FinalSession   = Convert.ToDateTime(tbFinalSession.Text, cul);
                eval.TotalNSession  = tbTotalSession.Text;
                eval.Discharge1     = tbDischarge.Text;
                eval.GoalsBool      = rbGoals.SelectedValue;
                eval.Comments       = tbComments.Text;
                club.Discharges.AddObject(eval);
                club.SaveChanges();
                EID   = eval.ID;
                saved = true;
            }
        }
        private void Save()
        {
            DateTime date = Convert.ToDateTime(tbDate.Text, cul);
            int      id   = Convert.ToInt32(tbID.Text);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                // get employee
                string name  = User.Identity.Name;
                int    empID = (from o in club.Employees
                                where o.UserName == name
                                select o.EmpID).First();

                TReaquest re = new TReaquest();
                re.ClientID    = id;
                re.EmployeeID  = empID;
                re.Diagnosis   = tbDia.Text;
                re.Goals       = tbGoals.Text;
                re.Precautions = tbPrecaution.Text;
                re.Date        = date;
                club.TReaquests.AddObject(re);
                club.SaveChanges();
                EID   = re.ID;
                saved = true;
            }
        }
Esempio n. 11
0
        protected void btnEAdd_Click(object sender, EventArgs e)
        {
            string name  = tbEName.Text;
            long   phone = Convert.ToInt64(tbPhone.Text);
            int    dep   = Convert.ToInt32(ddlType.SelectedValue);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                var emp = club.Employees.Where(a => a.EmpID == EditEmp).First();
                emp.Name     = name;
                emp.PhoneNum = phone;
                if (dep == 0)
                {
                    emp.Type = "Manager";
                }
                else
                {
                    emp.Type = "Trainer";
                    var t = (from o in club.Departments
                             where o.DepID == dep
                             select o).First();
                    emp.Departments.Clear();
                    emp.Departments.Add(t);
                }
                club.SaveChanges();
                resetEmp();
                gvEmp.DataSource = club.getEmployees();
                gvEmp.DataBind();
                //chagesSaved();
            }
        }
Esempio n. 12
0
        protected void btnEAdd_Click(object sender, EventArgs e)
        {
            string name  = tbEName.Text;
            long   phone = Convert.ToInt64(tbPhone.Text);
            int    dep   = Convert.ToInt32(ddlType.SelectedValue);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                Employee emp = new Employee();
                emp.Name     = name;
                emp.PhoneNum = phone;
                if (dep == 8)
                {
                    emp.Type = "Manager";
                }
                else
                {
                    emp.Type = "Trainer";
                    var t = (from o in club.Departments
                             where o.DepID == dep
                             select o).First();
                    emp.Departments.Add(t);
                }
                club.Employees.AddObject(emp);
                club.SaveChanges();
                chagesSaved();
            }
        }
Esempio n. 13
0
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            string  toPerson = tbTo.Text;
            decimal amount   = Convert.ToDecimal(tbAmount.Text);
            string  amountW  = tbAmountW.Text;
            string  note     = tbNotes.Text;
            long?   check    = null;
            string  bank     = "";

            if (pnlBank.Visible)
            {
                check = Convert.ToInt64(tbCheck.Text);
                bank  = tbBank.Text;
            }
            using (ClubDBEntities club = new ClubDBEntities())
            {
                string username = User.Identity.Name;
                var    emp      = (from o in club.Employees
                                   where o.UserName == username
                                   select o.EmpID).First();
                Withdraw with = new Withdraw();
                with.Amount   = amount;
                with.AmountW  = amountW;
                with.Bank     = bank;
                with.CheckNum = check;
                with.Date     = DateTime.Now.Date;
                with.EmpID    = emp;
                with.Notes    = note;
                with.ToPerson = toPerson;
                club.Withdraws.AddObject(with);
                club.SaveChanges();
            }
            Response.Redirect("Default.aspx");
        }
Esempio n. 14
0
        protected void btnDAdd_Click(object sender, EventArgs e)
        {
            string name = tbDName.Text;

            using (ClubDBEntities club = new ClubDBEntities())
            {
                Department dep = new Department();
                dep.Name = name;
                club.Departments.AddObject(dep);
                club.SaveChanges();
                chagesSaved();
            }
        }
Esempio n. 15
0
        private void SaveInfo()
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                DateTime date = Convert.ToDateTime(tbDate.Text);
                // buffet
                BuffetMov buff = new BuffetMov();
                buff.Date       = date;
                buff.Balance    = Convert.ToDecimal(tbTIncome.Text);
                buff.PreBalance = Convert.ToDecimal(tbPreBalance.Text);
                buff.MigBalance = Convert.ToDecimal(tbMigBalance.Text);
                buff.Purchase   = Convert.ToDecimal(tbIncome.Text);
                buff.Sales      = Convert.ToDecimal(tbSales.Text);
                club.BuffetMovs.AddObject(buff);

                // ohda
                //ExpensesMov ex = new ExpensesMov();
                //ex.Date = date;
                //ex.Balance = 0;
                //ex.Expenses = 0;
                //ex.MigBalance = 0;
                //ex.PlusBalance = 0;
                //ex.PreBalance = 0;
                //club.ExpensesMovs.AddObject(ex);

                // cash
                //CashMov cash = new CashMov();
                //cash.Date = date;
                //cash.Balance = Convert.ToDecimal(tbCTotal.Text);
                //cash.Bank = Convert.ToDecimal(tbCBank.Text);
                //cash.BuffetIncome = 0;
                //cash.Expenses = Convert.ToDecimal(tbCExpenses.Text);
                //cash.InvIncome = Convert.ToDecimal(tbCIncome.Text);
                //cash.MigBalance = Convert.ToDecimal(tbCMigBalance.Text);
                //cash.PreBalance = Convert.ToDecimal(tbCPreBalance.Text);
                //club.CashMovs.AddObject(cash);
                try
                {
                    club.SaveChanges();
                    saved            = true;
                    Date             = date;
                    lblError.Visible = false;
                }
                catch
                {
                    lblError.Text    = "خطأ في التاريخ. الرجاء التأكد من المعلومات";
                    lblError.Visible = true;
                }
            }
        }
Esempio n. 16
0
        protected void btnDAdd_Click(object sender, EventArgs e)
        {
            string name = tbDName.Text;

            using (ClubDBEntities club = new ClubDBEntities())
            {
                var d = (from i in club.Departments where i.DepID == EditDep select i).First();
                d.Name = tbDName.Text;
                club.SaveChanges();
                DepTable.Visible = false;
                tbDName.Text     = "";
                gvDep.DataSource = club.Departments;
                gvDep.DataBind();
            }
        }
Esempio n. 17
0
        protected void btnWSave_Click(object sender, EventArgs e)
        {
            int    dep  = Convert.ToInt32(ddlWDep.SelectedValue);
            string name = tbWName.Text;

            using (ClubDBEntities club = new ClubDBEntities())
            {
                WithType with = new WithType();
                with.Department = dep;
                with.Name       = name;
                club.WithTypes.AddObject(with);
                club.SaveChanges();
                chagesSaved();
            }
        }
Esempio n. 18
0
        private void updateInvoice(int invoiceID)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                // get the invoice then update data
                InvoiceHeader invoice = (from o in club.InvoiceHeaders
                                         where o.InvID == invoiceID
                                         select o).First();
                invoice.Date        = Convert.ToDateTime(tbDate.Text);
                invoice.ClientID    = Convert.ToInt32(tbFile.Text);
                invoice.Discount    = Convert.ToInt32(tbDis.Text);
                invoice.FinalAmount = Convert.ToDecimal(tbFinal.Text);
                invoice.Type        = rbType.SelectedValue;

                club.SaveChanges();
                InvID = invoiceID;
            }
        }
Esempio n. 19
0
        protected void btnWSave_Click(object sender, EventArgs e)
        {
            string name = tbWName.Text;
            int    dep  = Convert.ToInt32(ddlWDep.SelectedValue);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                var u = (from i in club.WithTypes
                         where i.ID == EditWith
                         select i).First();
                u.Name       = name;
                u.Department = dep;

                club.SaveChanges();
                tbWName.Text          = "";
                ddlWDep.SelectedIndex = 0;
                withTable.Visible     = false;
                gvWith.DataSource     = club.getWithTypes();
                gvWith.DataBind();
            }
        }
Esempio n. 20
0
        private string saveInvoice(out int invoiceN)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                // get info


                int     clientID = Convert.ToInt32(tbFile.Text);
                decimal total    = Convert.ToDecimal(tbTotal.Text);
                int     dis      = (string.IsNullOrEmpty(tbDis.Text)) ? 0 : Convert.ToInt32(tbDis.Text);
                decimal final    = Convert.ToDecimal(tbFinal.Text);
                //decimal rem = (string.IsNullOrEmpty(tbRemain.Text)) ? 0 : Convert.ToDecimal(tbRemain.Text);
                int           dep = Convert.ToInt32(ddlDep.SelectedValue);
                InvoiceHeader inv = new InvoiceHeader();
                inv.ClientID    = clientID;
                inv.TotalAmount = total;
                inv.Discount    = dis;
                inv.FinalAmount = final;
                inv.Dep         = dep;
                inv.Notes       = tbNotes.Text;
                inv.DocID       = Convert.ToInt32(ddlDoc.SelectedValue);
                string userName = User.Identity.Name;
                inv.Status    = InvoiceStatus.Incomplete.ToString();
                inv.RecepName = userName;
                inv.Date      = DateTime.Now.Date;

                // services
                var services = from o in club.Services
                               where ids.Contains(o.ServiceID)
                               select o;
                foreach (var s in services)
                {
                    inv.Services.Add(s);
                }
                club.InvoiceHeaders.AddObject(inv);
                club.SaveChanges();
                invoiceN = inv.InvID;
                return(inv.Status);
            }
        }
Esempio n. 21
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                lblError.Visible = false;
                var sub = (from i in club.Subscribtions
                           where i.SubID == SubID
                           select i).First();
                if (sub.LeftDays - 1 < 0)
                {
                    // dont save
                    lblNo.Text       = "انتهت أيام الاشتراك، لا يمكنك اضافة زيارة";
                    pnlVisit.Visible = false;
                    return;
                }
                else
                {
                    sub.LeftDays--;
                    sub.AttDays++;
                    Visit visit = new Visit();
                    visit.ClientID   = CntID;
                    visit.SubID      = SubID;
                    visit.Date       = DateTime.Now.Date;
                    visit.SigninTime = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                    visit.SizeAfter  = tbAfter.Text;
                    visit.SizeBefore = tbBefore.Text;
                    club.Visits.AddObject(visit);
                    club.SaveChanges();
                    var result = club.getSubDetails(SubID);
                    fvDetails.DataSource = result;
                    fvDetails.DataBind();
                }

                // refresh
                EntityDataSource1.DataBind();
                gvVisits.DataBind();

                pnlVisit.Visible = false;
            }
        }
Esempio n. 22
0
        protected void btnSAdd_Click(object sender, EventArgs e)
        {
            bool    sub   = (rbSType.SelectedIndex == 0) ? false : true;
            string  name  = tbSName.Text;
            decimal price = Convert.ToDecimal(tbPrice.Text);
            int     days  = string.IsNullOrEmpty(tbDays.Text)?0:Convert.ToInt32(tbDays.Text);
            int     dep   = Convert.ToInt32(ddlSDep.SelectedValue);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                var ser = club.Services.Where(a => a.ServiceID == EditSer).First();
                ser.Name      = name;
                ser.Sub       = sub;
                ser.Price     = price;
                ser.TotalDays = days;
                ser.DepID     = dep;
                club.SaveChanges();
                gvSer.DataSource = club.getServices();
                gvSer.DataBind();
                resetSer();
            }
        }
Esempio n. 23
0
        protected void btnSAdd_Click(object sender, EventArgs e)
        {
            bool    sub   = (rbSType.SelectedIndex == 0) ? false : true;
            string  name  = tbSName.Text;
            decimal price = Convert.ToDecimal(tbPrice.Text);
            int     days  = string.IsNullOrEmpty(tbDays.Text)?0:Convert.ToInt32(tbDays.Text);
            int     dep   = Convert.ToInt32(ddlSDep.SelectedValue);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                Service ser = new Service();
                ser.Name      = name;
                ser.Price     = price;
                ser.Sub       = sub;
                ser.TotalDays = days;
                ser.DepID     = dep;

                club.Services.AddObject(ser);
                club.SaveChanges();
                chagesSaved();
            }
        }
Esempio n. 24
0
        protected void gvDep_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(gvDep.Rows[e.RowIndex].Cells[3].Text);

            try
            {
                using (ClubDBEntities club = new ClubDBEntities())
                {
                    var dep = club.Departments.Where(a => a.DepID == id).First();
                    club.Departments.DeleteObject(dep);
                    club.SaveChanges();
                    gvDep.DataSource = club.Departments;
                    gvDep.DataBind();
                    string Message = " تم الحذف  ";
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);
                }
            }
            catch
            {
                lblError.Text    = "لايمكن حذف العيادة";
                lblError.Visible = true;
            }
        }
Esempio n. 25
0
        protected void gvSer_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(gvSer.Rows[e.RowIndex].Cells[7].Text);

            using (ClubDBEntities club = new ClubDBEntities())
            {
                try
                {
                    var re = club.Services.Where(a => a.ServiceID == id).First();
                    club.Services.DeleteObject(re);
                    club.SaveChanges();
                    gvSer.DataSource = club.getServices();
                    gvSer.DataBind();
                    string Message = " تم الحذف  ";
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);
                }
                catch
                {
                    lblError.Text    = "لايمكن الحذف";
                    lblError.Visible = true;
                }
            }
        }
Esempio n. 26
0
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            string toPerson = tbTo.Text;

            decimal amount  = Convert.ToDecimal(tbAmount.Text);
            string  amountW = tbAmountW.Text;
            string  note    = tbNotes.Text;
            long?   check   = null;
            string  bank    = "";

            if (pnlBank.Visible)
            {
                check = Convert.ToInt64(tbCheck.Text);
                bank  = tbBank.Text;
            }
            using (ClubDBEntities club = new ClubDBEntities())
            {
                string username = User.Identity.Name;
                var    emp      = (from o in club.Employees
                                   where o.UserName == username
                                   select o).First();
                Deposit deposit = new Deposit();
                deposit.Amount     = amount;
                deposit.AmountW    = amountW;
                deposit.Bank       = bank;
                deposit.CheckNum   = check;
                deposit.Date       = DateTime.Now.Date;
                deposit.Notes      = note;
                deposit.Employee   = toPerson;
                deposit.FromPerson = tbFrom.Text;
                deposit.InvID      = invID;
                club.Deposits.AddObject(deposit);
                club.SaveChanges();
            }
            Response.Redirect("Default.aspx");
        }
Esempio n. 27
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (edit)
            {
                using (ClubDBEntities club = new ClubDBEntities())
                {
                    var result = (from o in club.Subscribtions
                                  where o.SubID == sub.SubID
                                  select o).First();
                    result.Measurements = tbMeasurements.Text;
                    result.Diagnosis    = tbDiagnosis.Text;
                    switch (sub.Service.DepID)
                    {
                    case 1:
                        var nut = (from o in club.NutSubs
                                   where o.SubID == sub.SubID
                                   select o).First();
                        nut.Weight = tbWeight.Text;
                        nut.Hight  = tbHieght.Text;
                        nut.Fat    = tbFat.Text;
                        club.SaveChanges();
                        break;

                    case 2:
                        var iint = (from o in club.IntSubs
                                    where o.SubID == sub.SubID
                                    select o).First();
                        iint.BloodSugar    = tbBSugar.Text;
                        iint.BloodPressure = tbBPressure.Text;
                        club.SaveChanges();
                        break;

                    case 5:
                        club.SaveChanges();
                        break;
                    }
                }
                string Message = "تم حفظ التعديلات";
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);
            }
            else
            {
                lblError.Visible = false;
                int id      = Convert.ToInt32(tbFile.Text);
                int empID   = Convert.ToInt32(ddlDoc.SelectedValue);
                int service = Convert.ToInt32(ddlServices.SelectedValue);
                if (ddlDep.SelectedIndex != 0)
                {
                    int subId;
                    using (ClubDBEntities club = new ClubDBEntities())
                    {
                        var serviceDays = (from o in club.Services
                                           where o.ServiceID == service
                                           select o.TotalDays).First();
                        Subscribtion sub = new Subscribtion();
                        sub.ClientID  = id;
                        sub.Date      = DateTime.Now;
                        sub.LeftDays  = serviceDays;
                        sub.ServiceID = service;
                        sub.AttDays   = 0;
                        sub.SubDays   = serviceDays;
                        club.Subscribtions.AddObject(sub);
                        club.SaveChanges();
                        subId = sub.SubID;
                        switch (ddlDep.SelectedValue)
                        {
                        case "1":
                            sub.Diagnosis    = tbDiagnosis.Text;
                            sub.Measurements = tbMeasurements.Text;
                            NutSub nut = new NutSub();
                            nut.Fat    = tbFat.Text;
                            nut.Weight = tbWeight.Text;
                            nut.Hight  = tbHieght.Text;
                            nut.SubID  = subId;
                            club.NutSubs.AddObject(nut);
                            club.SaveChanges();
                            break;

                        case "2":
                            sub.Diagnosis    = tbDiagnosis.Text;
                            sub.Measurements = tbMeasurements.Text;
                            IntSub Int = new IntSub();
                            Int.BloodPressure = tbBPressure.Text;
                            Int.BloodSugar    = tbBSugar.Text;
                            club.IntSubs.AddObject(Int);
                            club.SaveChanges();
                            break;

                        case "5":
                            sub.Diagnosis    = tbDiagnosis.Text;
                            sub.Measurements = tbMeasurements.Text;
                            club.SaveChanges();
                            break;
                        }
                    }
                    // redirect to the invoice
                    Response.Redirect("Invoice.aspx?subID=" + subId + "&empID=" + empID);
                }
                else
                {
                    lblError.Text    = "الرجاء اختيار القسم";
                    lblError.Visible = true;
                }
            }
        }
Esempio n. 28
0
        private void SaveInfo(bool ed)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                DateTime date = Convert.ToDateTime(tbDate.Text);
                if (ed)
                {
                    var re = club.CashMovs.Where(a => a.Date == date).First();
                    re.Balance      = Convert.ToDecimal(tbCTotal.Text);
                    re.Bank         = Convert.ToDecimal(tbCBank.Text);
                    re.BuffetIncome = 0;
                    re.Expenses     = Convert.ToDecimal(tbCExpenses.Text);
                    re.InvIncome    = Convert.ToDecimal(tbCIncome.Text);
                    re.MigBalance   = Convert.ToDecimal(tbCMigBalance.Text);
                    re.PreBalance   = Convert.ToDecimal(tbCPreBalance.Text);
                    if (re.Bank > 0)
                    {
                        BankTran b = new BankTran();
                        b.Amount = re.Bank;
                        b.Note   = "إيداع نقدي";
                        b.Date   = Convert.ToDateTime(tbBankDate.Text);
                        club.BankTrans.AddObject(b);
                        re.BankID = b.ID;
                    }
                    else if (re.Bank == 0)
                    {
                        var b = club.BankTrans.Where(a => a.ID == re.BankID).FirstOrDefault();
                        if (b != null)
                        {
                            club.BankTrans.DeleteObject(b);
                        }
                    }
                }
                else
                {
                    // buffet
                    //BuffetMov buff = new BuffetMov();
                    //buff.Date = date;
                    //buff.Balance = Convert.ToDecimal(tbTIncome.Text);
                    //buff.PreBalance = Convert.ToDecimal(tbPreBalance.Text);
                    //buff.MigBalance = Convert.ToDecimal(tbMigBalance.Text);
                    //buff.Purchase = Convert.ToDecimal(tbIncome.Text);
                    //buff.Sales = Convert.ToDecimal(tbSales.Text);
                    //club.BuffetMovs.AddObject(buff);

                    // ohda
                    //ExpensesMov ex = new ExpensesMov();
                    //ex.Date = date;
                    //ex.Balance = 0;
                    //ex.Expenses = 0;
                    //ex.MigBalance = 0;
                    //ex.PlusBalance = 0;
                    //ex.PreBalance = 0;
                    //club.ExpensesMovs.AddObject(ex);

                    // cash
                    CashMov cash = new CashMov();
                    cash.Date         = date;
                    cash.Balance      = Convert.ToDecimal(tbCTotal.Text);
                    cash.Bank         = Convert.ToDecimal(tbCBank.Text);
                    cash.BuffetIncome = 0;
                    cash.Expenses     = Convert.ToDecimal(tbCExpenses.Text);
                    cash.InvIncome    = Convert.ToDecimal(tbCIncome.Text);
                    cash.MigBalance   = Convert.ToDecimal(tbCMigBalance.Text);
                    cash.PreBalance   = Convert.ToDecimal(tbCPreBalance.Text);
                    club.CashMovs.AddObject(cash);

                    // bank
                    if (cash.Bank > 0)
                    {
                        BankTran b = new BankTran();
                        b.Amount = cash.Bank;
                        b.Note   = "إيداع نقدي";
                        b.Date   = Convert.ToDateTime(tbBankDate.Text);
                        club.BankTrans.AddObject(b);
                        cash.BankID = b.ID;
                    }
                }
                try
                {
                    club.SaveChanges();

                    saved            = true;
                    Date             = date;
                    lblError.Visible = false;
                    string Message = " تم حفظ المعلومات  ";
                    ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert", string.Format("alert('{0}');", Message), true);
                }
                catch
                {
                    lblError.Text    = "خطأ في التاريخ. الرجاء التأكد من المعلومات";
                    lblError.Visible = true;
                }
            }
        }
Esempio n. 29
0
        private string saveInvoice(out int invoiceN)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                // get info
                int     clientID = Convert.ToInt32(tbFile.Text);
                decimal total    = Convert.ToDecimal(tbTotal.Text);
                int     dis      = (string.IsNullOrEmpty(tbDis.Text)) ? 0 : Convert.ToInt32(tbDis.Text);
                decimal final    = Convert.ToDecimal(tbFinal.Text);
                decimal rem      = (string.IsNullOrEmpty(tbRemain.Text)) ? 0 : Convert.ToDecimal(tbRemain.Text);
                //int dep = Convert.ToInt32(ddlDep.SelectedValue);
                InvoiceHeader inv = new InvoiceHeader();
                inv.ClientID    = clientID;
                inv.TotalAmount = total;
                inv.Discount    = dis;
                inv.FinalAmount = final;
                //inv.Dep = dep;
                inv.Notes = tbNotes.Text;
                inv.Type  = rbType.SelectedValue;
                //inv.DocID = Convert.ToInt32(ddlDoc.SelectedValue);
                string userName = User.Identity.Name;
                inv.Status = InvoiceStatus.Complete.ToString();

                inv.RecepName = userName;
                inv.Date      = Convert.ToDateTime(tbDate.Text);//DateTime.Now.Date;// TODO: chnage this

                // services

                club.InvoiceHeaders.AddObject(inv);
                club.SaveChanges();
                invoiceN = inv.InvID;
                var services = (from o in club.Services
                                where ids.Contains(o.ServiceID)
                                select o).ToList();
                foreach (var s in services)
                {
                    // create  a sub if sub
                    if (s.Sub)
                    {
                        Subscribtion sub = new Subscribtion();
                        sub.ClientID  = clientID;
                        sub.Date      = Convert.ToDateTime(tbDate.Text);
                        sub.ServiceID = s.ServiceID;
                        sub.AttDays   = 0;
                        sub.LeftDays  = s.TotalDays;
                        sub.SubDays   = s.TotalDays;
                        club.Subscribtions.AddObject(sub);
                        club.SaveChanges();
                        switch (s.DepID)
                        {
                        case 1:
                            NutSub nut = new NutSub();
                            nut.SubID = sub.SubID;
                            club.NutSubs.AddObject(nut);
                            club.SaveChanges();
                            break;

                        case 2:
                            IntSub Int = new IntSub();
                            Int.SubID = sub.SubID;
                            club.IntSubs.AddObject(Int);
                            club.SaveChanges();
                            break;
                        }
                    }
                    // create a service
                    InvoiceService ser = new InvoiceService();
                    ser.InvID     = inv.InvID;
                    ser.ServiceID = s.ServiceID;
                    if (dis == 0)
                    {
                        if (rbType.SelectedIndex == 1)
                        {
                            decimal paid = Convert.ToDecimal(string.IsNullOrEmpty(tbPaid.Text) ? "0" : tbPaid.Text);
                            ser.PaidAmount  = getPrecentage(s.Price, final, paid);
                            ser.AskedAmount = s.Price;
                            ser.Percentage  = s.Price / final;
                        }

                        else
                        {
                            ser.PaidAmount  = s.Price;
                            ser.AskedAmount = s.Price;
                            ser.Percentage  = s.Price / final;
                        }
                    }
                    else
                    {
                        if (rbType.SelectedIndex == 1)
                        {
                            decimal paid    = Convert.ToDecimal(string.IsNullOrEmpty(tbPaid.Text) ? "0" : tbPaid.Text);
                            decimal asked   = applyDis(dis, s.Price);
                            decimal serpaid = getPrecentage(s.Price, final, paid);
                            ser.AskedAmount = asked;
                            ser.PaidAmount  = serpaid;
                            ser.Percentage  = s.Price / final;
                        }
                        else
                        {
                            decimal asked = applyDis(dis, s.Price);
                            ser.AskedAmount = asked;
                            ser.PaidAmount  = asked;
                            ser.Percentage  = s.Price / final;
                            //decimal paid = getPrecentage(asked, final, final);
                        }
                    }

                    club.InvoiceServices.AddObject(ser);
                }
                Deposit deposit = new Deposit();
                deposit.InvID      = invoiceN;
                deposit.Notes      = tbNotes.Text;
                deposit.Date       = Convert.ToDateTime(tbDate.Text);//DateTime.Now.Date;// TODO: chnage this
                deposit.Employee   = club.Employees.Where(a => a.UserName == User.Identity.Name).Select(o => o.Name).First();
                deposit.FromPerson = club.Clients.Where(a => a.ClientID == inv.ClientID).First().FullName();
                switch (rbType.SelectedIndex)
                {
                case 0:
                    deposit.CheckNum = Convert.ToInt64(tbCheck.Text);
                    deposit.Bank     = tbBank.Text;
                    inv.Type         = InvoiceType.Check.ToString();
                    break;

                case 1:
                    decimal paid = Convert.ToDecimal(tbPaid.Text);
                    deposit.Amount = paid;
                    inv.Type       = InvoiceType.Credit.ToString();
                    break;

                case 2:
                    decimal amount = Convert.ToDecimal(tbFinal.Text);
                    deposit.Amount = amount;
                    inv.Type       = InvoiceType.Cash.ToString();
                    break;
                }
                club.Deposits.AddObject(deposit);
                club.SaveChanges();
                VoucherID = deposit.ID;
                return(inv.Status);
            }
        }
Esempio n. 30
0
        private string saveInvoice(out int invoiceN)
        {
            using (ClubDBEntities club = new ClubDBEntities())
            {
                // get info


                int           clientID = Convert.ToInt32(tbFile.Text);
                decimal       total    = Convert.ToDecimal(tbTotal.Text);
                int           dis      = (string.IsNullOrEmpty(tbDis.Text)) ? 0 : Convert.ToInt32(tbDis.Text);
                decimal       final    = Convert.ToDecimal(tbFinal.Text);
                decimal       rem      = (string.IsNullOrEmpty(tbRemain.Text)) ? 0 : Convert.ToDecimal(tbRemain.Text);
                int           dep      = Convert.ToInt32(ddlDep.SelectedValue);
                InvoiceHeader inv      = new InvoiceHeader();
                inv.ClientID    = clientID;
                inv.TotalAmount = total;
                inv.Discount    = dis;
                inv.FinalAmount = final;
                inv.Dep         = dep;
                inv.Notes       = tbNotes.Text;
                inv.Type        = rbType.SelectedValue;
                inv.DocID       = Convert.ToInt32(ddlDoc.SelectedValue);
                string userName = User.Identity.Name;
                inv.Status = InvoiceStatus.Complete.ToString();

                inv.RecepName = userName;
                inv.Date      = DateTime.Now.Date;

                // services
                var services = from o in club.Services
                               where ids.Contains(o.ServiceID)
                               select o;
                foreach (var s in services)
                {
                    inv.Services.Add(s);
                }
                club.InvoiceHeaders.AddObject(inv);
                club.SaveChanges();
                invoiceN = inv.InvID;
                Deposit deposit = new Deposit();
                deposit.InvID      = invoiceN;
                deposit.Notes      = tbNotes.Text;
                deposit.Date       = DateTime.Now.Date;
                deposit.Employee   = club.Employees.Where(a => a.UserName == User.Identity.Name).Select(o => o.Name).First();
                deposit.FromPerson = club.Clients.Where(a => a.ClientID == inv.ClientID).First().FullName();
                switch (rbType.SelectedIndex)
                {
                case 0:
                    deposit.CheckNum = Convert.ToInt64(tbCheck.Text);
                    deposit.Bank     = tbBank.Text;
                    inv.Type         = InvoiceType.Check.ToString();
                    break;

                case 1:
                    decimal paid = Convert.ToDecimal(tbPaid.Text);
                    deposit.Amount = paid;
                    inv.Type       = InvoiceType.Credit.ToString();
                    break;

                case 2:
                    decimal amount = Convert.ToDecimal(tbFinal.Text);
                    deposit.Amount = amount;
                    inv.Type       = InvoiceType.Cash.ToString();
                    break;
                }
                club.Deposits.AddObject(deposit);
                club.SaveChanges();
                VoucherID = deposit.ID;
                return(inv.Status);
            }
        }