//public static void RegisterRemoteFeedbackLesson<TEntity>(this ModelSource<TEntity> models,IQueryable<LessonTime> items = null)
        //    where TEntity : class, new()
        //{
        //    var catalog = models.GetTable<ObjectiveLessonCatalog>().Where(c => c.CatalogID == (int)ObjectiveLessonCatalog.CatalogDefinition.OnLineFeedback)
        //            .FirstOrDefault();

        //    var price = catalog?.ObjectiveLessonPrice.FirstOrDefault();

        //    if (price == null)
        //    {
        //        return;
        //    }

        //    var exceptive = models.GetTable<UserRole>().Where(r => r.RoleID == (int)Naming.RoleID.Dietitian);
        //    var exceptivePrice = models.GetTable<ObjectiveLessonPrice>()
        //            .Where(b => b.CatalogID == (int)ObjectiveLessonCatalog.CatalogDefinition.OnLineFeedback
        //                || b.CatalogID == (int)ObjectiveLessonCatalog.CatalogDefinition.OnLine)
        //            .Select(b => b.PriceID)
        //            .ToArray();

        //    if (items == null)
        //    {
        //        items = models.GetTable<LessonTime>();
        //    }

        //    items = items
        //        .Where(l => !exceptive.Any(x => x.UID == l.AttendingCoach))
        //        .Join(models.PromptVirtualClassOccurrence(),
        //            l => l.BranchID, b => b.BranchID, (l, b) => l);

        //    items = items
        //            .Join(models.GetTable<V_LessonTime>()
        //                .Where(t => t.CoachAttendance.HasValue)
        //                .Where(t => t.CommitAttendance.HasValue)
        //                .Where(t => !exceptivePrice.Contains(t.PriceID))
        //                .Where(t => SessionScopeForRemoteFeedback.Contains(t.PriceStatus)),
        //            l => l.LessonID, t => t.LessonID, (l, t) => l);

        //    var calcItems = items.GroupBy(l => l.GroupID);
        //    var table = models.GetTable<RegisterLesson>();

        //    var groupingCount = calcItems.Select(g => new
        //    {
        //        g.First().GroupingLesson,
        //        UID = g.First().GroupingLesson.RegisterLesson.Select(r => r.UID).OrderBy(u => u).ToArray(),
        //        TotalCount = g.Count()
        //    })
        //        .ToList()
        //        .GroupBy(g => g.UID.JsonStringify())
        //        .Select(g => new
        //        {
        //            g.First().GroupingLesson,
        //            UID = g.Key,
        //            TotalCount = g.Sum(v => v.TotalCount),
        //        });

        //    foreach (var g in groupingCount)
        //    {
        //        var lesson = g.GroupingLesson;
        //        var item = lesson.RegisterLesson.First();
        //        GroupingLesson groupLesson = null;
        //        foreach (var uid in JsonConvert.DeserializeObject<int[]>(g.UID))
        //        {
        //            var currentFeedback = table
        //                .Where(r => r.ClassLevel == price.PriceID)
        //                .Where(r => r.UID == uid)
        //                .FirstOrDefault();

        //            if (currentFeedback == null)
        //            {
        //                if (groupLesson == null)
        //                {
        //                    groupLesson = new GroupingLesson { };
        //                }

        //                currentFeedback = new RegisterLesson
        //                {
        //                    UID = uid,
        //                    RegisterDate = DateTime.Now,
        //                    BranchID = item.BranchID,
        //                    GroupingMemberCount = item.GroupingMemberCount,
        //                    ClassLevel = price.PriceID,
        //                    IntuitionCharge = new IntuitionCharge
        //                    {
        //                        ByInstallments = 1,
        //                        Payment = "Cash",
        //                        FeeShared = 0
        //                    },
        //                    Attended = (int)Naming.LessonStatus.準備上課,
        //                    AdvisorID = item.AdvisorID,
        //                    AttendedLessons = 0,
        //                    GroupingLesson = groupLesson,
        //                };

        //                table.InsertOnSubmit(currentFeedback);
        //            }

        //            if (currentFeedback.Lessons < g.TotalCount)
        //            {
        //                currentFeedback.Lessons = g.TotalCount;
        //                currentFeedback.Attended = (int)Naming.LessonStatus.準備上課;
        //            }

        //            models.SubmitChanges();

        //        }
        //    }
        //}

        public static bool ValidateMeetingRoom(this String url, BranchStore branch, GenericManager <BFDataContext> models)
        {
            bool check    = false;
            var  branchID = branch.BranchID;

            url = url?.ToLower();
            if (url != null)
            {
                var c = models.GetTable <ObjectiveLessonLocation>()
                        .Where(l => l.BranchID == branchID)
                        .Where(l => l.CatalogID == (int)ObjectiveLessonCatalog.CatalogDefinition.OnLine)
                        .Where(l => l.PreferredUrl != null)
                        .FirstOrDefault();
                if (c != null)
                {
                    check = false;
                    foreach (var place in JsonConvert.DeserializeObject <String[]>(c.PreferredUrl))
                    {
                        if (url.StartsWith(place.ToLower()))
                        {
                            check = true;
                            break;
                        }
                    }
                }
            }

            return(check);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lock (Database.lockObjectDB)
            {
                //alldata = sc.UserAction(User.Identity.Name, Restrictions.FilialDeliver);
                current_branch_id = sc.BranchId(User.Identity.Name);
                //if (current_branch_id == 106) alldata = true;
                //else alldata = false;
                int branchIdMain = BranchStore.getBranchMainFilial(current_branch_id, false);
                if (branchIdMain > 0 && branchIdMain == current_branch_id)
                {
                    alldata = true;
                }
                else
                {
                    alldata = false;
                }
                dListStatus.AutoPostBack = alldata;

                branch_main_filial = BranchStore.getBranchMainFilial(current_branch_id, sc.UserAction(User.Identity.Name, Restrictions.Perso));

                if (FIO_state.Trim().Length > 0)
                {
                    tbFio.Text = FIO_state;
                }

                if (!IsPostBack)
                {
                    ZapCombo();
                    tbNumber.Focus();
                }
            }
        }
        private void Btn_selectedStore_Click(object sender, RoutedEventArgs e)
        {//select one
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_branchList);
                }

                branch = dg_allStores.SelectedItem as Branch;

                if (branch != null)
                {
                    allStores.Remove(branch);
                    if (userOrBranch == 'u')
                    {
                        BranchesUsers bu = new BranchesUsers();
                        bu.branchsUsersId = 0;
                        bu.branchId       = branch.branchId;
                        bu.userId         = Id;
                        bu.bname          = branch.name;
                        bu.createUserId   = MainWindow.userID;

                        selectedStoresByUser.Add(bu);

                        dg_selectedStores.ItemsSource = selectedStoresByUser;
                    }
                    else
                    {
                        BranchStore bs = new BranchStore();
                        bs.id           = 0;
                        bs.branchId     = branch.branchId;
                        bs.storeId      = branch.branchId;
                        bs.createUserId = MainWindow.userID;
                        bs.sname        = branch.name;
                        bs.bname        = branch.name;
                        bs.isActive     = 1;
                        selectedStoresByBranch.Add(bs);
                        dg_selectedStores.ItemsSource = selectedStoresByBranch;
                    }

                    dg_allStores.ItemsSource = allStores;

                    dg_allStores.Items.Refresh();
                    dg_selectedStores.Items.Refresh();
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_branchList);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_branchList);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Exemplo n.º 4
0
        private void FillBranch()
        {
            ListRequest           branchesRequest = new ListRequest();
            ListResponse <Branch> resp            = _companyStructureService.ChildGetAll <Branch>(branchesRequest);

            BranchStore.DataSource = resp.Items;
            BranchStore.DataBind();
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DialogUtils.SetScriptSubmit(this);

            ClientScript.RegisterHiddenField("resd", "");


            perso = sc.UserAction(User.Identity.Name, Restrictions.Perso);

            branch_current     = sc.BranchId(User.Identity.Name);
            branch_main_filial = BranchStore.getBranchMainFilial(branch_current, perso);

            if (sc.UserAction(User.Identity.Name, Restrictions.AllData))
            {
                branchSearch = " (1=1) ";
            }
            else
            {
                branchSearch = String.Format(" (id_branchCard={0} or id_branchCard in (select id from Branchs where id_parent={0} or id_parentTr={0}))", sc.BranchId(User.Identity.Name));
            }
            if (!sc.UserAction(User.Identity.Name, Restrictions.CardsView))
            {
                Response.Redirect("~\\Account\\Restricted.aspx", true);
            }



            if (IsPostBack)
            {
                return;
            }

            lock (Database.lockObjectDB)
            {
                gvCard.PageSize = 50;

                // Решили оставить страницу с картами певоначально пустой
                lbSearch.Text = "where 1=0";

                //if (ServiceClass.UserAction(User.Identity.Name, Restrictions.Filial))
                //    lbSearch.Text = " where id_stat=4 ";
                //else
                //    lbSearch.Text = " where id_stat=2 ";
                lbSort.Text = "order by dateProd desc,DepBranchCard,company,fio";
                Refr(true);
            }
            if (!sc.UserAction(User.Identity.Name, Restrictions.CardsDelete))
            {
                bDeleteCards.Visible = false;
            }
            if (!sc.UserAction(User.Identity.Name, Restrictions.CardsGive))
            {
                bFilCards.Visible = false;
            }
            GC.Collect();

            Session["Card"] = this;
        }
        private void Btn_unSelectedStore_Click(object sender, RoutedEventArgs e)
        {//unselect one
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_branchList);
                }

                if (userOrBranch == 'u')
                {
                    branchUser = dg_selectedStores.SelectedItem as BranchesUsers;

                    if (branchUser != null)
                    {
                        branch = allStoresSource.Where(s => s.branchId == branchUser.branchId.Value).FirstOrDefault();
                        //branch = await branchModel.getBranchById(branchUser.branchId.Value);

                        selectedStoresByUser.Remove(branchUser);

                        dg_selectedStores.ItemsSource = selectedStoresByUser;
                    }
                }
                else
                {
                    branchStore = dg_selectedStores.SelectedItem as BranchStore;

                    if (branchStore != null)
                    {
                        branch = allStoresSource.Where(s => s.branchId == branchStore.storeId.Value).FirstOrDefault();
                        //branch = await branchModel.getBranchById(branchStore.branchId.Value);
                        selectedStoresByBranch.Remove(branchStore);

                        dg_selectedStores.ItemsSource = selectedStoresByBranch;
                    }
                }

                allStores.Add(branch);
                dg_allStores.ItemsSource = allStores;
                dg_allStores.Items.Refresh();
                dg_selectedStores.Items.Refresh();

                if (sender != null)
                {
                    SectionData.EndAwait(grid_branchList);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_branchList);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
Exemplo n.º 7
0
        private void FillBranch()
        {
            ListRequest           branchesRequest = new ListRequest();
            ListResponse <Branch> resp            = _companyStructureService.ChildGetAll <Branch>(branchesRequest);

            if (!resp.Success)
            {
                Common.errorMessage(resp);
            }
            BranchStore.DataSource = resp.Items;
            BranchStore.DataBind();
        }
Exemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     lock (Database.lockObjectDB)
     {
         perso              = sc.UserAction(User.Identity.Name, Restrictions.Perso);
         branch_current     = sc.BranchId(User.Identity.Name);
         branch_main_filial = BranchStore.getBranchMainFilial(branch_current, perso);
         if (!IsPostBack)
         {
             ZapCombo();
         }
     }
 }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Accountable = SingleQuery.IsAccountable(User.Identity.Name);
            lock (Database.lockObjectDB)
            {
                Filial             = sc.UserAction(User.Identity.Name, Restrictions.Filial);
                Perso              = sc.UserAction(User.Identity.Name, Restrictions.Perso);
                FilialDeliver      = sc.UserAction(User.Identity.Name, Restrictions.FilialDeliver);
                current_branch     = sc.BranchId(User.Identity.Name);
                branch_main_filial = BranchStore.getBranchMainFilial(current_branch, Perso);

                if (!IsPostBack)
                {
                    ZapCombo();
                    tbProd.Focus();
                }
            }
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            isAccountBranchView = sc.UserAction(User.Identity.Name, Restrictions.AccountBranchView);

            if (!sc.UserAction(User.Identity.Name, Restrictions.LibraryView) && isAccountBranchView == false)
            {
                Response.Redirect("~\\Account\\Restricted.aspx", true);
            }
            ClientScript.RegisterHiddenField("resd", "");
            if (FuncClass.ClientType != ClientType.AkBars)
            {
                isAccountBranchView = false;
                isAccountBranchEdit = false;
            }

            perso          = sc.UserAction(User.Identity.Name, Restrictions.Perso);
            branch_current = sc.BranchId(User.Identity.Name);

            branch_main_filial = BranchStore.getBranchMainFilial(branch_current, perso);

            isAccountBranchEdit = sc.UserAction(User.Identity.Name, Restrictions.AccountBranchEdit);

            if (isAccountBranchView == false)
            {
                isAccountBranchEdit = false;
            }

            lbInform.Text = "";

            oprdaystart = operDayStart.ClientID;
            oprdayend   = operDayEnd.ClientID;

            if (IsPostBack)
            {
                return;
            }

            lock (Database.lockObjectDB)
            {
                lbInform.Text = "";
                Refr(0);
            }
            raschet = "";
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lock (Database.lockObjectDB)
            {
                if (!sc.UserAction(User.Identity.Name, Restrictions.LibraryOrgEdit))
                {
                    Response.Redirect("~\\Account\\Restricted.aspx", true);
                }
                ClientScript.RegisterHiddenField("resd", "");

                perso              = sc.UserAction(User.Identity.Name, Restrictions.Perso);
                current_branch     = sc.BranchId(User.Identity.Name);
                branch_main_filial = BranchStore.getBranchMainFilial(current_branch, perso);

                if (!IsPostBack)
                {
                    lbInform.Text = "";
                    Refr(0);
                }
            }
        }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            superusername = "******";
            try
            {
                string str = ConfigurationManager.AppSettings["ClientType"];
                if (str.ToLower() == "uzcard")
                {
                    superusername = "******";
                }
            }
            catch
            {
            }


            if (!sc.UserAction(User.Identity.Name, Restrictions.StorageView) && !sc.UserAction(User.Identity.Name, Restrictions.StorageFilial))
            {
                Response.Redirect("~\\Account\\Restricted.aspx", true);
            }

            ClientScript.RegisterHiddenField("resd", "");


            current_branch_id  = sc.BranchId(User.Identity.Name);
            branch_main_filial = BranchStore.getBranchMainFilial(current_branch_id, sc.UserAction(User.Identity.Name, Restrictions.Perso));
            //showChild.Visible = current_branch_id==106;
            branchIdMain      = BranchStore.getBranchMainFilial(current_branch_id, false);
            showChild.Visible = current_branch_id == branchIdMain;

            lock (Database.lockObjectDB)
            {
                if (!IsPostBack)
                {
                    lbSort.Text = "order by id_type,id_sort";
                    Refr(true);
                }
            }
            GC.Collect();
        }
Exemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lock (Database.lockObjectDB)
            {
                if (!sc.UserAction(User.Identity.Name, Restrictions.LibraryOrgEdit))
                {
                    Response.Redirect("~\\Account\\Restricted.aspx", true);
                }

                perso              = sc.UserAction(User.Identity.Name, Restrictions.Perso);
                current_branch     = sc.BranchId(User.Identity.Name);
                branch_main_filial = BranchStore.getBranchMainFilial(current_branch, perso);

                if (!IsPostBack)
                {
                    if (Request.QueryString["mode"] == "2")
                    {
                        ZapFields();
                    }
                    tbName.Focus();
                }
            }
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lock (Database.lockObjectDB)
            {
                perso              = sc.UserAction(User.Identity.Name, Restrictions.Perso);
                current_branch     = sc.BranchId(User.Identity.Name);
                branch_main_filial = BranchStore.getBranchMainFilial(current_branch, perso);

                /*
                 * if (!sc.UserAction(User.Identity.Name, Restrictions.LibraryOrgEdit)
                 *                  && branch_main_filial != 106) // Костыль для казанского филиала!!!
                 * Response.Redirect("~\\Account\\Restricted.aspx", true);
                 */

                if (!IsPostBack)
                {
                    SqlCommand comm = new SqlCommand();
                    //comm.CommandText = String.Format("select idP, person from V_Org where embosstitle='{0}'", Request.QueryString["etitle"].ToString());
                    if (branch_main_filial > 0)
                    {
                        comm.CommandText = String.Format("select idP, person from V_Org where embosstitle='{0}' and BranchMainFilialId={1}", Request.QueryString["etitle"].ToString(), branch_main_filial);
                    }
                    else
                    {
                        comm.CommandText = String.Format("select idP, person from V_Org where embosstitle='{0}' and BranchMainFilialId is null", Request.QueryString["etitle"].ToString());
                    }

                    DataSet ds = new DataSet();
                    Database.ExecuteCommand(comm, ref ds, null);
                    rblList.DataTextField  = "Person";
                    rblList.DataValueField = "idP";
                    rblList.DataSource     = ds.Tables[0];
                    rblList.DataBind();
                    rblList.SelectedIndex = 0;
                }
            }
        }
Exemplo n.º 15
0
        private ActionResult CommitRemoteTrialLesson(LessonTimeViewModel viewModel, BranchStore branch, ServingCoach coach)
        {
            RegisterLesson lesson;
            UserProfile    profileItem = models.GetTable <UserProfile>().Where(u => u.UID == viewModel.UID).FirstOrDefault();

            if (profileItem == null)
            {
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "體驗學員資料錯誤!!"));
            }

            var priceType = models.CurrentTrialLessonPrice(true, viewModel.PriceID);

            if (priceType == null)
            {
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml", model: "體驗課程類型錯誤!!"));
            }

            lesson = new RegisterLesson
            {
                UID                 = viewModel.UID.Value,
                RegisterDate        = DateTime.Now,
                GroupingMemberCount = 1,
                Lessons             = 1,
                ClassLevel          = priceType.PriceID,
                IntuitionCharge     = new IntuitionCharge
                {
                    ByInstallments = 1,
                    Payment        = "Cash",
                    FeeShared      = 0
                },
                AdvisorID      = viewModel.CoachID,
                BranchID       = branch.BranchID,
                GroupingLesson = new GroupingLesson {
                }
            };
            //var installment = new TuitionInstallment
            //{
            //    PayoffDate = viewModel.ClassDate,
            //    PayoffAmount = priceType.ListPrice,
            //    Payment = new Payment
            //    {
            //        PayoffAmount = priceType.ListPrice,
            //        PayoffDate = viewModel.ClassDate
            //    }
            //};
            //installment.Payment.TuitionAchievement.Add(new TuitionAchievement
            //{
            //    CoachID = lesson.AdvisorID.Value,
            //    ShareAmount = installment.PayoffAmount
            //});

            //lesson.IntuitionCharge.TuitionInstallment.Add(installment);
            models.GetTable <RegisterLesson>().InsertOnSubmit(lesson);
            models.SubmitChanges();


            LessonTime timeItem = new LessonTime
            {
                InvitedCoach      = viewModel.CoachID,
                AttendingCoach    = viewModel.CoachID,
                ClassTime         = viewModel.ClassDate,
                DurationInMinutes = priceType.DurationInMinutes,
                TrainingBySelf    = (int)Naming.LessonSelfTraining.體驗課程,
                RegisterID        = lesson.RegisterID,
                LessonPlan        = new LessonPlan
                {
                },
                BranchID             = branch.BranchID,
                LessonTimeSettlement = new LessonTimeSettlement
                {
                    ProfessionalLevelID = coach.LevelID.Value,
                    MarkedGradeIndex    = coach.LevelID.HasValue ? coach.ProfessionalLevel.GradeIndex : null,
                    CoachWorkPlace      = coach.WorkBranchID(),
                }
            };

            if (models.GetTable <DailyWorkingHour>().Any(d => d.Hour == viewModel.ClassDate.Value.Hour))
            {
                timeItem.HourOfClassTime = viewModel.ClassDate.Value.Hour;
            }

            timeItem.GroupID = lesson.RegisterGroupID;
            timeItem.LessonFitnessAssessment.Add(new LessonFitnessAssessment
            {
                UID = lesson.UID
            });
            models.GetTable <LessonTime>().InsertOnSubmit(timeItem);

            try
            {
                models.SubmitChanges();
                timeItem.BookingLessonTimeExpansion(models, timeItem.ClassTime.Value, timeItem.DurationInMinutes.Value);
            }
            catch (Exception ex)
            {
                models.ExecuteCommand("delete RegisterLesson where RegisterID = {0}", lesson.RegisterID);

                Logger.Error(ex);
                ViewBag.Message = "預約未完成,請重新預約!!";
                return(View("~/Views/ConsoleHome/Shared/JsAlert.cshtml"));
            }

            return(Json(new { result = true, message = "上課時間預約完成!!" }));
        }
Exemplo n.º 16
0
        protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e)
        {
            WebLog.LogClass.WriteToLog($"{sessionId} Login {LoginUser.UserName} authenticate starting");
            LoginUser.FailureText = "Данный логин/пароль не найден";
            HttpContext.Current.Session["BranchId"]    = null;
            HttpContext.Current.Session["UserActions"] = null;
            if (LoginUser.UserName == superusername && LoginUser.Password == superusername.ToLower())
            {
                e.Authenticated = true;
                OstCard.Data.Database.Log(sc.UserGuid(superusername), "Вход в систему", null);
                WebLog.LogClass.WriteToLog($"{sessionId} Login {LoginUser.UserName} authenticate success");
                return;
            }
            else
            {
                WebLog.LogClass.WriteToLog($"{sessionId} Login {LoginUser.UserName} validation starting ");
                bool auth = System.Web.Security.Membership.ValidateUser(LoginUser.UserName, LoginUser.Password);
                if (auth == true)
                {
                    WebLog.LogClass.WriteToLog($"{sessionId} Login {LoginUser.UserName} validation success");
                    WebLog.LogClass.WriteToLog($"{sessionId} Login {LoginUser.UserName} branch choosing");
                    // Проверяем на Казанский филиал и может ли он логинится в любой филиал
                    int branchId     = sc.BranchId(LoginUser.UserName);
                    int branchIdMain = BranchStore.getBranchMainFilial(branchId, false);

                    string   abu             = System.Configuration.ConfigurationManager.AppSettings["AllBranchsUser"];
                    string[] allbranchsusers = abu?.Split(',');

                    ArrayList al = new ArrayList();
                    DataSet   ds = new DataSet();

                    if (allbranchsusers.Contains(LoginUser.UserName))
                    {
                        lock (OstCard.Data.Database.lockObjectDB)
                        {
                            OstCard.Data.Database.ExecuteQuery("select id, department from branchs order by department", ref ds, null);
                            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                            {
                                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                {
                                    BranchStore branchItem = new BranchStore(Convert.ToInt32(ds.Tables[0].Rows[i]["id"]), "", ds.Tables[0].Rows[i]["department"].ToString());
                                    if (branchItem.id == branchId)
                                    {
                                        branchItem.ident_dep = "select";
                                    }
                                    al.Add(branchItem);
                                }
                            }
                        }
                    }
                    else
                    {
                        //if (branchId == 106) // Казанский филиал - можно выбрать все подчиненные
                        if (branchIdMain > 0)
                        {
                            lock (OstCard.Data.Database.lockObjectDB)
                            {
                                //OstCard.Data.Database.ExecuteQuery("select id, department from branchs where id=106 or id_parent=106 order by id", ref ds, null);
                                OstCard.Data.Database.ExecuteQuery(string.Format("select id, department from branchs where id={0} or id_parent={0} order by id", branchIdMain), ref ds, null);
                                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                                {
                                    //if (branchId == 106)
                                    if (branchId == branchIdMain)
                                    {
                                        BranchStore branchItem = new BranchStore(-1, "", "Выберите филиал");
                                        branchItem.ident_dep = "select";
                                        al.Add(branchItem);
                                    }
                                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                    {
                                        BranchStore branchItem = new BranchStore(Convert.ToInt32(ds.Tables[0].Rows[i]["id"]), "", ds.Tables[0].Rows[i]["department"].ToString());
                                        //if (branchItem.id == branchId && branchId!=106) branchItem.ident_dep = "select";
                                        if (branchItem.id == branchId && branchId != branchIdMain)
                                        {
                                            branchItem.ident_dep = "select";
                                        }
                                        al.Add(branchItem);
                                    }
                                }
                            }
                        }
                        else // Ищем подчиненные Казанского филиала
                        {
                            lock (OstCard.Data.Database.lockObjectDB)
                            {
                                //OstCard.Data.Database.ExecuteQuery("select id, department from branchs where id_parent=106 and id=" + branchId, ref ds, null);
                                OstCard.Data.Database.ExecuteQuery("select id, department from branchs where id_parent=" + branchIdMain + " and id=" + branchId, ref ds, null);
                                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                                {
                                    //OstCard.Data.Database.ExecuteQuery("select id, department from branchs where id_parent=106 order by id", ref ds, null);
                                    OstCard.Data.Database.ExecuteQuery("select id, department from branchs where id_parent=" + branchIdMain + " order by id", ref ds, null);
                                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                                    {
                                        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                        {
                                            BranchStore branchItem = new BranchStore(Convert.ToInt32(ds.Tables[0].Rows[i]["id"]), "", ds.Tables[0].Rows[i]["department"].ToString());
                                            if (branchItem.id == branchId)
                                            {
                                                branchItem.ident_dep = "select";
                                            }
                                            al.Add(branchItem);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    DropDownList dList = getBranch();
                    if (dList.Items.Count > 1 && dList.SelectedIndex >= 0)
                    {
                        if (Convert.ToInt32(dList.Items[dList.SelectedIndex].Value) > 0)
                        {
                            HttpContext.Current.Session["BranchId"]        = dList.Items[dList.SelectedIndex].Value;
                            HttpContext.Current.Session["CurrentUserName"] = LoginUser.UserName.ToLower();
                            HttpContext.Current.Session["CurrentUserId"]   = sc.UserId(LoginUser.UserName);
                        }
                        else
                        {
                            dList.Items.Clear();
                        }
                    }

                    if (dList.Items.Count < 1 && al.Count > 0 && dList.SelectedIndex < 0)
                    {
                        for (int i = 0; i < al.Count; i++)
                        {
                            BranchStore b = (BranchStore)al[i];
                            dList.Items.Add(new ListItem(b.department, b.id.ToString()));
                            if (b.ident_dep == "select")
                            {
                                dList.SelectedIndex = i;
                            }
                        }
                        getBranchLabel().Visible = true;
                        getBranch().Visible      = true;
                        auth = false;
                        LoginUser.FailureText = "Необходимо указать подразделение";
                        String id_pasword      = LoginUser.FindControl("Password").ClientID;
                        String id_paswordLabel = LoginUser.FindControl("PasswordLabel").ClientID;
                        String id_branch       = LoginUser.FindControl("Branch").ClientID;
                        ClientScript.RegisterClientScriptBlock(GetType(), "focus42",
                                                               "<script type='text/javascript'>$(document).ready(function(){ " +
                                                               "$('#" + id_pasword + "').val('" + LoginUser.Password + "');" +
                                                               "$('#" + id_branch + "').focus();" +
                                                               //"$('#" + id_paswordLabel + "').css('display','none');" +
                                                               //"$('#" + id_pasword + "').css('display','none');" +
                                                               //"$('#" + id_pasword + "').attr('disabled', true);" +
                                                               "});</script>");
                    }
                }
                else
                {
                    WebLog.LogClass.WriteToLog($"{sessionId} Login {LoginUser.UserName} validation failed");
                    getBranchLabel().Visible = false;
                    getBranch().Visible      = false;
                }
                WebLog.LogClass.WriteToLog($"{sessionId} Login {LoginUser.UserName} authenticate result {auth}");
                e.Authenticated = auth;
            }
        }
Exemplo n.º 17
0
        protected void ValidateCommonBooking(LessonTimeViewModel viewModel, out ServingCoach coach, out BranchStore branch)
        {
            if (!viewModel.ClassDate.HasValue)
            {
                ModelState.AddModelError("ClassDate", "請選擇上課日期!!");
            }
            else if (viewModel.ClassDate < DateTime.Today)
            {
                ModelState.AddModelError("ClassDate", "預約時間不可早於今天!!");
            }

            branch = null;
            if (!viewModel.BranchID.HasValue)
            {
                ModelState.AddModelError("BranchID", "請選擇上課地點!!");
            }
            else
            {
                branch = models.GetTable <BranchStore>().Where(b => b.BranchID == viewModel.BranchID).FirstOrDefault();
            }

            coach = models.GetTable <ServingCoach>().Where(s => s.CoachID == viewModel.CoachID).FirstOrDefault();
            if (coach == null)
            {
                ModelState.AddModelError("CoachID", "未指定體能顧問!!");
            }

            viewModel.Place = viewModel.Place.GetEfficientString();
            if (branch?.IsVirtualClassroom() == true)
            {
                if (!viewModel.Place.ValidateMeetingRoom(branch, models))
                {
                    ModelState.AddModelError("Place", "請輸入正確會議室連結!!");
                }
            }
        }
Exemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
            {
                Response.Write("<script language=javascript>window.returnValue='1'; window.close();</script>");
                return;
            }
            Session["First"] = true;

            lock (Database.lockObjectDB)
            {
                perso = sc.UserAction(User.Identity.Name, Restrictions.Perso);

                branch_current     = sc.BranchId(User.Identity.Name);
                branch_main_filial = BranchStore.getBranchMainFilial(branch_current, perso);

                id_doc  = Convert.ToInt32(Request.QueryString["id_doc"]);
                id_type = Convert.ToInt32(Request.QueryString["type_doc"]);
                if (Request.QueryString["id_branch"] != "")
                {
                    id_branch = Convert.ToInt32(Request.QueryString["id_branch"]);
                }
                //bSave.Enabled = false;
                if (id_type == (int)TypeDoc.ToBook124)
                {
                    stat = "(id_stat=4) and (DateClient is null) and id_prop=1";
                    if (branch_main_filial > 0 && branch_main_filial != branch_current)
                    {
                        stat += " and id_BranchCurrent=" + branch_current.ToString();
                    }
                }
                if (id_type == (int)TypeDoc.FromBook124)
                {
                    stat = "(id_stat=19)";
                    if (branch_main_filial > 0 && branch_main_filial != branch_current)
                    {
                        stat += " and id_BranchCurrent=" + branch_current.ToString();
                    }
                }
                if (id_type == (int)TypeDoc.ToGoz)
                {
                    stat = "(id_stat=4) and (DateClient is null) and id_prop=1";
                    if (branch_main_filial > 0 && branch_main_filial != branch_current)
                    {
                        stat += " and id_BranchCurrent=" + branch_current.ToString();
                    }
                }
                if (id_type == (int)TypeDoc.FromGoz)
                {
                    stat = "(id_stat=24)";
                    if (branch_main_filial > 0 && branch_main_filial != branch_current)
                    {
                        stat += " and id_BranchCurrent=" + branch_current.ToString();
                    }
                }
                if (id_type == (int)TypeDoc.SendToClient)
                {
                    // 24.07.20 - для книги 124 было что выдавать может только тот, на ком числится. Теперь выдавать может любой сотрудник филиала
                    //stat = $"(id_stat=4 or ((id_stat=19 or id_stat=24) and id_person={sc.UserId(User.Identity.Name)})) and (DateClient is null) and id_prop=1";
                    stat = $"((id_stat=4 or id_stat=19) or (id_stat=24 and id_person={sc.UserId(User.Identity.Name)})) and (DateClient is null) and id_prop=1";
                    if (branch_main_filial > 0 && branch_main_filial != branch_current)
                    {
                        stat += " and id_BranchCurrent=" + branch_current.ToString();
                    }
                }

                if (id_type == (int)TypeDoc.SendToBank)
                {
                    stat = "id_stat=4";
                    if (branch_main_filial > 0 && branch_main_filial != branch_current)
                    {
                        stat += " and id_BranchCurrent=" + branch_current.ToString();
                    }
                }

                if (id_type == (int)TypeDoc.KillingCard)
                {
                    stat = "(id_stat=4 or id_stat=6)";
                }
                if (id_type == (int)TypeDoc.ReturnToFilial)
                {
                    stat = "id_stat=8";
                }
                if (id_type == (int)TypeDoc.FilialFilial)
                {
                    stat = "id_stat=4";
                }
                if (id_type == (int)TypeDoc.SendToPodotchet)
                {
                    stat = "id_stat=4";
                }
                if (id_type == (int)TypeDoc.FromGozToPodotchet)
                {
                    stat = "id_stat=24";
                }
                if (id_type == (int)TypeDoc.SendToClientFromPodotchet)
                {
                    stat = $"id_stat=15 and id_person=(select id_person from [AccountablePerson_StorageDocs] where id_doc={id_doc})";
                }
                if (id_type == (int)TypeDoc.ReceiveFromPodotchet)
                {
                    stat = $"id_stat=15 and id_person=(select id_person from [AccountablePerson_StorageDocs] where id_doc={id_doc})";
                }
                if (id_type == (int)TypeDoc.ToGozFromPodotchet)
                {
                    stat = $"id_stat=15 and id_person=(select id_person from [AccountablePerson_StorageDocs] where id_doc={id_doc})";
                }


                if (NotSend.Checked == true)
                {
                    id_prb = getExcludeProductsCardsSelect();
                    if (stat.Length > 0)
                    {
                        stat += " and ";
                    }
                    //stat += "datestart is not null and datediff(month,datestart,getdate())>=3";
                    //stat += "datestart is not null and datediff(day,datestart,getdate())>90"; //03.02.2021 поменял на 180 дней
                    stat += "datestart is not null and datediff(day,datestart,getdate())>180";
                    if (id_prb.Length > 0)
                    {
                        stat += " and id_prb not in (" + id_prb + ")";
                    }
                }

                if (!IsPostBack)
                {
                    ZapCombo();
                    tbNumber.Focus();
                    //Refr();
                    NotSend.Text = " (более 6-х месяцев)";
                }

                Session["StorDocCardRec"] = null;
                Session["StorDocCardRec"] = this;
            }
        }
Exemplo n.º 19
0
 public void TestMethod1()
 {
     var branches = new BranchStore <IdentityBranch>(new MySQLDatabase()).GetAllBranchesAsync();
 }
Exemplo n.º 20
0
        public static IEnumerable <DailyBranchReportItem> BuildDailyPaymentReportForBranch(this IEnumerable <PaymentMonthlyReportItem> details, BranchStore branch)
        {
            var items = details.Where(d => d.分店 == branch.BranchName);
            IEnumerable <DailyBranchReportItem> results = items.GroupBy(d => d.日期).Select(g => new DailyBranchReportItem
            {
                日期   = g.Key,
                收款總計 = g.Sum(i => i.收款金額_含稅),
                現金收款 = g.Where(i => i.摘要.Contains("現金")).Sum(i => i.收款金額_含稅),
                轉帳收款 = g.Where(i => i.摘要.Contains("轉帳")).Sum(i => i.收款金額_含稅),
                刷卡收款 = g.Where(i => i.摘要.Contains("刷卡")).Sum(i => i.收款金額_含稅),
                作廢總計 = g.Where(i => i.摘要.Contains("作廢")).Sum(i => i.退款金額_含稅),
                終止退款 = g.Where(i => i.摘要.Contains("終止退款")).Sum(i => i.退款金額_含稅),
                終止轉收 = g.Where(i => i.摘要.Contains("終止轉收")).Sum(i => i.退款金額_含稅),
            }).ToList();

            foreach (var r in results)
            {
                r.實際收款 = r.收款總計 - r.作廢總計;
            }
            return(results);
        }