Exemplo n.º 1
0
        static void Main(string[] args)
        {
            PeopleBLL peopleBLL = new PeopleBLL();

            Console.WriteLine($"Сейчас есть {peopleBLL.CountStudent()} студентов.");

            peopleBLL.ShowAllSudents();
        }
Exemplo n.º 2
0
    private static Guid?ImportPeople(RedBloodDataContext db, People outerP)
    {
        //Importing people
        if (outerP == null || db == null)
        {
            return(null);
        }

        People innerP = PeopleBLL.GetByID(outerP.ID);

        if (innerP == null)
        {
            People newP = new People();

            newP.Name    = outerP.Name;
            newP.DOB     = outerP.DOB;
            newP.DOBYear = outerP.DOBYear;
            newP.CMND    = outerP.CMND;
            newP.SexID   = outerP.SexID;

            GeoBLL.Insert(
                outerP.ResidentGeo1 != null ? outerP.ResidentGeo1.Name : ""
                , outerP.ResidentGeo2 != null ? outerP.ResidentGeo2.Name : ""
                , outerP.ResidentGeo3 != null ? outerP.ResidentGeo3.Name : "");

            newP.ResidentAddress = outerP.ResidentAddress;
            newP.SetResidentGeo3(outerP.FullResidentalGeo);

            if (outerP.EnableMailingAddress.HasValue &&
                outerP.EnableMailingAddress.Value)
            {
                GeoBLL.Insert(
                    outerP.MailingGeo1 != null ? outerP.MailingGeo1.Name : ""
                    , outerP.MailingGeo2 != null ? outerP.MailingGeo2.Name : ""
                    , outerP.MailingGeo3 != null ? outerP.MailingGeo3.Name : "");

                newP.MailingAddress = outerP.MailingAddress;
                newP.SetMailingGeo3(outerP.FullMaillingGeo);

                newP.EnableMailingAddress = outerP.EnableMailingAddress;
            }

            newP.Job   = outerP.Job;
            newP.Email = outerP.Email;
            newP.Phone = outerP.Phone;
            newP.Note  = outerP.Note;

            db.Peoples.InsertOnSubmit(newP);
            db.SubmitChanges();

            return(newP.ID);
        }
        else
        {
            return(innerP.ID);
        }
    }
Exemplo n.º 3
0
    protected void LoadPersonData()
    {
        if (string.IsNullOrEmpty(PersonIdHiddenField.Value) || PersonIdHiddenField.Value == "0")
        {
            //Insert
            DataControl.OrganizationId = 0;
        }
        else
        {
            PermissionObject theUser = new PermissionObject();
            try
            {
                theUser = PermissionObjectBLL.GetPermissionsByUser(PermissionObject.ObjectType.PERSON.ToString(), Convert.ToInt32(PersonIdHiddenField.Value));
            }
            catch (Exception exc)
            {
                SystemMessages.DisplaySystemErrorMessage(exc.Message);
                Response.Redirect("~/Organization/ListOrganizations.aspx");
            }

            bool readOnly = false;

            if (theUser == null || !theUser.TheActionList.Exists(i => i.ObjectActionID.Equals("OWN") || i.ObjectActionID.Equals("MAN_PEOPLE")))
            {
                readOnly = true;
            }

            DataControl.ReadOnly = readOnly;

            //Update
            People theData = null;

            try
            {
                theData = PeopleBLL.GetPeopleById(Convert.ToInt32(PersonIdHiddenField.Value));
            }
            catch (Exception exc)
            {
                SystemMessages.DisplaySystemErrorMessage(exc.Message);
            }

            if (theData != null)
            {
                TitleLiteral.Text          = theData.Name;
                CodeTextBox.Text           = theData.Id;
                NameTextBox.Text           = theData.Name;
                DataControl.OrganizationId = theData.OrganizationId;
                DataControl.AreaId         = theData.AreaId;
                CodeTextBox.Enabled        = !readOnly;
                NameTextBox.Enabled        = !readOnly;
                SaveButton.Visible         = !readOnly;
                ReqLabel.Visible           = !readOnly;
                Req1Label.Visible          = !readOnly;
            }
        }
    }
Exemplo n.º 4
0
    public void LoadPeople()
    {
        People e = PeopleBLL.GetByID(PeopleID);

        if (e == null)
        {
        }
        else
        {
            imgCodabar.ImageUrl = BarcodeBLL.Url4People(e.Autonum);

            txtName.Text = e.Name;
            txtCMND.Text = e.CMND;

            txtDOB.Text = e.DOBToString;

            if (ddlSex.Items.Count == 1)
            {
                ddlSex.DataBind();
            }

            ddlSex.SelectedValue = e.SexID.ToString();

            txtResidentAddress.Text = e.ResidentAddress;
            if (e.ResidentGeo1 != null)
            {
                txtResidentGeo.Text = e.FullResidentalGeo;
            }


            if (e.EnableMailingAddress == null)
            {
                chkEnableMaillingAddress.Checked = false;
            }
            else
            {
                chkEnableMaillingAddress.Checked = e.EnableMailingAddress.Value;
            }

            txtMailingAddress.Enabled = chkEnableMaillingAddress.Checked;
            txtMailingGeo.Enabled     = chkEnableMaillingAddress.Checked;

            txtMailingAddress.Text = e.MailingAddress;
            if (e.MailingGeo1 != null)
            {
                txtMailingGeo.Text = e.FullMaillingGeo;
            }

            txtJob.Text   = e.Job;
            txtEmail.Text = e.Email;
            txtPhone.Text = e.Phone;
            txtNote.Text  = e.Note;
        }
    }
Exemplo n.º 5
0
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        People thePerson = new People();

        thePerson.Id             = CodeTextBox.Text;
        thePerson.Name           = NameTextBox.Text;
        thePerson.OrganizationId = DataControl.OrganizationId;
        thePerson.AreaId         = DataControl.AreaId;

        if (PersonId == 0)
        {
            //Insert
            try
            {
                PeopleBLL.InsertPeople(thePerson);
            }
            catch (Exception ex)
            {
                SystemMessages.DisplaySystemErrorMessage(ex.Message);
                return;
            }

            SystemMessages.DisplaySystemMessage(Resources.People.MessageCreatePersonOk);
        }
        else
        {
            //Update
            thePerson.PersonId = PersonId;
            try
            {
                PeopleBLL.UpdatePeople(thePerson);
            }
            catch (Exception ex)
            {
                SystemMessages.DisplaySystemErrorMessage(ex.Message);
                return;
            }

            SystemMessages.DisplaySystemMessage(Resources.People.MessageUpdatePersonOk);
        }
        Response.Redirect("~/Personas/ListaPersonas.aspx");
    }
Exemplo n.º 6
0
    protected void PersonRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int personId = 0;

        try
        {
            personId = Convert.ToInt32(e.CommandArgument);
        }
        catch (Exception ex)
        {
            log.Error("Error getting object id", ex);
        }
        if (personId <= 0)
        {
            SystemMessages.DisplaySystemErrorMessage(Resources.Organization.MessageNoComplete);
            return;
        }

        if (e.CommandName == "Restore")
        {
            try
            {
                TrashBLL.RestoreTrash(PersonHF.Value, personId);
            }
            catch (Exception ex)
            {
                SystemMessages.DisplaySystemErrorMessage(ex.Message);
                return;
            }
            PersonRepeater.DataBind();
        }
        if (e.CommandName == "DeletePerson")
        {
            try
            {
                PeopleBLL.DeletePermanently(personId);
            }
            catch (Exception ex)
            {
                SystemMessages.DisplaySystemErrorMessage(ex.Message);
                return;
            }
            PersonRepeater.DataBind();
        }
    }
Exemplo n.º 7
0
 private void LoadPerson()
 {
     if (PersonId > 0)
     {
         People theData = null;
         try
         {
             theData = PeopleBLL.GetPeopleById(PersonId);
         }
         catch (Exception exc)
         {
             SystemMessages.DisplaySystemErrorMessage(exc.Message);
         }
         if (theData != null)
         {
             OrganizationId = theData.OrganizationId;
             AreaId         = theData.AreaId;
         }
     }
 }
Exemplo n.º 8
0
    public static List <People> Get_People(string organizationId, string areaId, string filter)
    {
        List <People> theList = new List <People>();

        if (string.IsNullOrEmpty(areaId))
        {
            areaId = "0";
        }
        if (!string.IsNullOrEmpty(organizationId))
        {
            try
            {
                theList = PeopleBLL.GetPeopleForAutocomplete(Convert.ToInt32(organizationId), Convert.ToInt32(areaId), filter);
            }
            catch (Exception exc)
            {
                log.Error("Error in GetPeopleForAutocomplete to filter: " + filter + ", organizationId: " + organizationId + " and areaId: " + areaId, exc);
            }
        }
        return(theList);
    }
Exemplo n.º 9
0
    private void LoadData()
    {
        //-- verify is user is OWNER
        PermissionObject theUser = new PermissionObject();

        try
        {
            theUser = PermissionObjectBLL.GetPermissionsByUser(PermissionObject.ObjectType.PERSON.ToString(), Convert.ToInt32(PersonIdHiddenField.Value));
        }
        catch (Exception exc)
        {
            SystemMessages.DisplaySystemErrorMessage(exc.Message);
            Response.Redirect("~/Personas/ListaPersonas.aspx");
        }

        if (theUser == null || !theUser.TheActionList.Exists(i => i.ObjectActionID.Equals("OWN")))
        {
            SystemMessages.DisplaySystemWarningMessage(Resources.ShareData.UserNotOwnPerson);
            Response.Redirect("~/Personas/ListaPersonas.aspx");
        }

        //-- show Data
        People theData = null;

        try
        {
            theData = PeopleBLL.GetPeopleById(Convert.ToInt32(PersonIdHiddenField.Value));
        }
        catch (Exception exc)
        {
            SystemMessages.DisplaySystemErrorMessage(exc.Message);
            Response.Redirect("~/Personas/ListaPersonas.aspx");
        }

        if (theData != null)
        {
            PersonNameLiteral.Text = theData.Name;
        }
    }
Exemplo n.º 10
0
        public ActionResult GetPeopleJson(Pagination pagination, string bzid)
        {
            PeopleBLL pbll = new PeopleBLL();

            pagination.p_kid         = "ID";
            pagination.p_fields      = "Name,LinkWay,Quarters,Planer,bzid";
            pagination.p_tablename   = "wg_people t";
            pagination.conditionJson = "bzid ='" + bzid + "' and quarters !='其他成员'";
            pagination.sidx          = "Planer";
            var watch    = CommonHelper.TimerStart();
            var data     = pbll.GetPeopleJson(pagination);
            var JsonData = new
            {
                rows     = data,
                total    = pagination.total,
                page     = pagination.page,
                records  = pagination.records,
                costtime = CommonHelper.TimerEnd(watch)
            };

            return(Content(JsonData.ToJson()));
        }
    public void LoadPeople()
    {
        PeopleBLL bll = new PeopleBLL();
        People e = bll.GetByID(PeopleID);

        if (e == null)
        {
        }
        else
        {
            txtName.Text = e.Name;
            txtCMND.Text = e.CMND;

            txtDOB.Text = e.DOBToString;

            ddlSex.SelectedValue = e.SexID.ToString();

            txtResidentAddress.Text = e.ResidentAddress;
            if (e.ResidentGeo1 != null)
                txtResidentGeo.Text = e.FullResidentalGeo;
        }
    }
Exemplo n.º 12
0
    private void LoadData()
    {
        //-- verify is user is OWNER
        //PermissionObject theUser = new PermissionObject();
        //try
        //{
        //    theUser = PermissionObjectBLL.GetPermissionsByUser(PermissionObject.ObjectType.PERSON.ToString(), Convert.ToInt32(PersonIdHiddenField.Value));
        //}
        //catch (Exception exc)
        //{
        //    SystemMessages.DisplaySystemErrorMessage(exc.Message);
        //    Response.Redirect("~/Personas/ListaPersonas.aspx");
        //}

        //if (theUser == null || !theUser.TheActionList.Exists(i => i.ObjectActionID.Equals("OWN")))
        //{
        //    SystemMessages.DisplaySystemWarningMessage(Resources.DataDetails.UserNotOwner);
        //    Response.Redirect("~/Personas/ListaPersonas.aspx");
        //}

        //-- show Data
        People theData = null;

        try
        {
            theData = PeopleBLL.GetPeopleById(Convert.ToInt32(PersonIdHiddenField.Value));
        }
        catch (Exception exc)
        {
            log.Error(exc.Message);
            SystemMessages.DisplaySystemErrorMessage(Resources.DataDetails.MessageErrorGetPersona);
            Response.Redirect("~/Personas/ListaPersonas.aspx");
        }

        if (theData != null)
        {
            TitleLabel.Text = theData.Name + " (" + theData.Id + ")";
        }
    }
Exemplo n.º 13
0
    public void LoadPeople()
    {
        People e = PeopleBLL.GetByID(PeopleID);

        if (e == null)
        {
        }
        else
        {
            txtName.Text = e.Name;
            txtCMND.Text = e.CMND;

            txtDOB.Text = e.DOBToString;

            ddlSex.SelectedValue = e.SexID.ToString();

            txtResidentAddress.Text = e.ResidentAddress;
            if (e.ResidentGeo1 != null)
            {
                txtResidentGeo.Text = e.FullResidentalGeo;
            }
        }
    }
Exemplo n.º 14
0
    private void LoadPerson()
    {
        if (PersonId > 0)
        {
            People theData = null;
            try
            {
                theData = PeopleBLL.GetPeopleById(PersonId);
            }
            catch (Exception exc)
            {
                SystemMessages.DisplaySystemErrorMessage(exc.Message);
            }
            if (theData != null)
            {
                if (DataTypeHiddenField.Value.Equals("KPI"))
                {
                    pnlAddPeople.Style["display"] = "none";
                    pnlKPIPeople.Style["display"] = "inline";
                    KPIPeopleText.Text            = theData.Name;
                    KPIPeopleText.Enabled         = !ReadOnly;
                    RemovePeopleButton.Visible    = !ReadOnly;

                    pnlKPIProject.Style["display"]  = "none";
                    pnlAddProject.Style["display"]  = "none";
                    pnlKPIActivity.Style["display"] = "none";
                    pnlAddActivity.Style["display"] = "none";

                    pnlKPIData.Style["display"] = "block";
                    pnlKPI.Style["display"]     = "none";
                }

                OrganizationId = theData.OrganizationId;
                AreaId         = theData.AreaId;
            }
        }
    }
    public void LoadPeople()
    {
        PeopleBLL bll = new PeopleBLL();

        People e = bll.GetByID(PeopleID);

        if (e == null)
        {

        }
        else
        {
            imgCodabar.ImageUrl = BarcodeBLL.Url4People(e.Autonum);

            txtName.Text = e.Name;
            txtCMND.Text = e.CMND;

            txtDOB.Text = e.DOBToString;

            if (ddlSex.Items.Count == 1)
                ddlSex.DataBind();

            ddlSex.SelectedValue = e.SexID.ToString();

            txtResidentAddress.Text = e.ResidentAddress;
            if (e.ResidentGeo1 != null)
                txtResidentGeo.Text = e.FullResidentalGeo;

            if (e.EnableMailingAddress == null)
                chkEnableMaillingAddress.Checked = false;
            else
                chkEnableMaillingAddress.Checked = e.EnableMailingAddress.Value;

            txtMailingAddress.Enabled = chkEnableMaillingAddress.Checked;
            txtMailingGeo.Enabled = chkEnableMaillingAddress.Checked;

            txtMailingAddress.Text = e.MailingAddress;
            if (e.MailingGeo1 != null)
                txtMailingGeo.Text = e.FullMaillingGeo;

            txtJob.Text = e.Job;
            txtEmail.Text = e.Email;
            txtPhone.Text = e.Phone;
            txtNote.Text = e.Note;
            btnPrintDINCard.NavigateUrl = RedBloodSystem.Url4PrintDINCard + "PeopleID=" + e.ID.ToString();
            btnPrintDINCard2.NavigateUrl = RedBloodSystem.Url4PrintDINCard2 + "PeopleID=" + e.ID.ToString();
        }
    }
Exemplo n.º 16
0
    //isSOD: isStartOfDate
    //public static void ScanExp(bool isSOD)
    //{
    //if (!isSOD || !LogBLL.IsLog(Task.TaskX.ScanExp))
    //{
    //    RedBloodDataContext db = new RedBloodDataContext();

    //    List<Pack.StatusX> statusList = new List<Pack.StatusX> { Pack.StatusX.Product };

    //    IQueryable<Pack> rs = db.Packs.Where(r => statusList.Contains(r.Status) && r.ExpirationDate < DateTime.Now.Date);

    //    foreach (Pack r in rs)
    //    {
    //        PackStatusHistory h = PackBLL.Update(db, r, Pack.StatusX.Expired, RedBloodSystem.SODActor, "");

    //        if (h != null) db.PackStatusHistories.InsertOnSubmit(h);
    //    }

    //    db.SubmitChanges();

    //    LogBLL.Add(Task.TaskX.ScanExp);
    //}
    //}

    //isSOD: isStartOfDate
    //public static void CloseOrder(bool isSOD)
    //{
    //    //if (!isSOD || !LogBLL.IsLog(Task.TaskX.CloseOrder))
    //    //{
    //    //    RedBloodDataContext db = new RedBloodDataContext();

    //    //    OrderBLL.CloseOrder(db);

    //    //    db.SubmitChanges();

    //    //    LogBLL.Add(Task.TaskX.CloseOrder);
    //    //}
    //}

    //isSOD: isStartOfDate
    //public static void LockTestResult()
    //{
    //if (!isSOD || !LogBLL.IsLog(Task.TaskX.LockEnterTestResult))
    //{
    //    RedBloodDataContext db = new RedBloodDataContext();

    //    PackBLL.LockEnterTestResult();

    //    db.SubmitChanges();

    //    LogBLL.Add(Task.TaskX.LockEnterTestResult);
    //}
    //}

    /// <summary>
    /// if true, count remaining packs directly in store
    /// else count by sum up the remaining of previous date and total transaction in day
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    //static bool IsCountDirectly(DateTime date)
    //{
    //    RedBloodDataContext db = new RedBloodDataContext();

    //    bool isCountDirectly = false;

    //    //new system, no data
    //    if (db.PackTransactions.Count() == 0)
    //        isCountDirectly = true;
    //    else
    //    {
    //        if (lastPackTransactionDate == null) throw new Exception("");
    //        else
    //        {
    //            GetLastTransactionDate();

    //            //All pack transactions were in the previous of the date.
    //            if (lastPackTransactionDate.Value.Date <= date.Date)
    //                isCountDirectly = true;
    //        }
    //    }
    //    return isCountDirectly;
    //}

    public static void Find(HttpResponse Response, TextBox txtCode)
    {
        if (txtCode == null)
        {
            return;
        }

        string key = txtCode.Text.Trim();

        if (key.Length == 0)
        {
            return;
        }

        string pattern = @"\d+";
        Regex  regx    = new Regex(pattern);

        if (BarcodeBLL.IsValidPeopleCode(key))
        {
            People r = PeopleBLL.GetByCode(key);
            if (r != null)
            {
                Response.Redirect(RedBloodSystem.Url4PeopleDetail + "key=" + r.ID.ToString());
            }
        }
        else if (BarcodeBLL.IsValidDINCode(key))
        {
            Response.Redirect(RedBloodSystem.Url4PackDetail + "key=" + BarcodeBLL.ParseDIN(key));
        }
        else if (BarcodeBLL.IsValidCampaignCode(key))
        {
            Campaign r = CampaignBLL.Get(BarcodeBLL.ParseCampaignID(key));
            if (r != null)
            {
                Response.Redirect(RedBloodSystem.Url4CampaignDetail + "key=" + r.ID.ToString());
            }
        }
        else if (BarcodeBLL.IsValidOrderCode(key))
        {
            Order r = OrderBLL.Get(BarcodeBLL.ParseOrderID(key));
            if (r != null)
            {
                Response.Redirect(RedBloodSystem.Url4Order4CR + "key=" + r.ID.ToString());
            }
        }
        //TODO: Search by name
        else if (key.Length > 3 && key.Substring(0, 3) == "/n:")
        {
            Response.Redirect(RedBloodSystem.Url4FindPeople + "key=" + key.Substring(3).Trim());
        }
        else if (regx.IsMatch(key) && key.Length >= BarcodeBLL.CMNDLength.ToInt())
        {
            People r = PeopleBLL.GetByCMND(key);
            if (r != null)
            {
                Response.Redirect(RedBloodSystem.Url4PeopleDetail + "key=" + r.ID.ToString());
            }
        }

        txtCode.Text = "";
    }
Exemplo n.º 17
0
    protected void PeopleRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int personId = 0;

        try
        {
            personId = Convert.ToInt32(e.CommandArgument);
        }
        catch (Exception ex)
        {
            log.Error("Error getting object id", ex);
        }
        if (personId <= 0)
        {
            SystemMessages.DisplaySystemErrorMessage(Resources.People.MessageNotAction);
            return;
        }

        if (e.CommandName.Equals("ViewPerson"))
        {
            Session["PERSONID"] = personId.ToString();
            Response.Redirect("~/People/PersonDetails.aspx");
        }
        if (e.CommandName == "EditPerson")
        {
            Session["PersonId"] = personId.ToString();
            Response.Redirect("~/Personas/PeopleForm.aspx");
        }
        if (e.CommandName == "DeletePerson")
        {
            try
            {
                PeopleBLL.DeletePeople(personId);
            }
            catch (Exception ex)
            {
                SystemMessages.DisplaySystemErrorMessage(ex.Message);
                return;
            }
            SystemMessages.DisplaySystemMessage(Resources.People.MessageDeletePersonOk);
            PeopleRepeater.DataBind();
        }
        if (e.CommandName == "ViewOrganization")
        {
            Session["SEARCH_PARAMETER"] = "@organizationID " + personId.ToString();
            Response.Redirect("~/Organization/ListOrganizations.aspx");
            return;
        }
        if (e.CommandName == "ViewArea")
        {
            Session["OrganizationId"] = personId.ToString();
            Response.Redirect("~/Organization/EditOrganization.aspx");
            return;
        }
        if (e.CommandName == "ViewKPIs")
        {
            Session["SEARCH_PARAMETER"] = "@personID " + personId.ToString();
            Response.Redirect("~/Kpi/KpiList.aspx");
            return;
        }
        if (e.CommandName.Equals("SharePerson"))
        {
            Session["PERSONID"] = personId.ToString();
            Response.Redirect("~/People/SharePerson.aspx");
        }
    }