Ejemplo n.º 1
0
        /// <summary>
        /// Update Database Make data as Obsoluted
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void IsObsolete_CheckedChanged(Object sender, EventArgs e)
        {
            string message = string.Empty;

            try
            {
                CheckBox    chk = (CheckBox)sender;
                GridViewRow gr  = (GridViewRow)chk.Parent.Parent;
                ViewState["BankBranchId"] = ((Literal)gr.FindControl("litBankBranchId")).Text;
                BranchBLL objBranchBLL = new BranchBLL();
                message = objBranchBLL.ObsoleteBranch(Convert.ToInt32(ViewState["BankBranchId"]), Convert.ToString(chk.Checked));
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data Updated successfully";
                }
                BindGrid();
                ClearDetails();
                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public ActionResult GetEmployee()
        {
            try
            {
                int      pageIndex = Convert.ToInt32(Request.QueryString["page"]);
                int      pageSize  = Convert.ToInt32(Request.QueryString["limit"]);
                string   branchIds = Request.QueryString["id"];
                string[] _ids      = branchIds.Split(',');
                int[]    ids       = Array.ConvertAll <string, int>(_ids, id =>
                {
                    return(int.Parse(id));
                });
                EmployeeBLL     eBll       = new EmployeeBLL();
                int             rows       = 0;
                int             totalPages = 0;
                List <Employee> list       = eBll.LoadPagedEntitys(pageIndex, pageSize, out rows, out totalPages, t => ids.Contains(t.branchId), true, t => t.Id);
                if (list != null && list.Count > 0)
                {
                    List <Branch> branchList = new BranchBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        branchList.ForEach(y =>
                        {
                            if (t.branchId == y.Id)
                            {
                                t.branchName = y.branchName;
                            }
                        });
                    });
                    List <Role> roleList = new RoleBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        roleList.ForEach(y =>
                        {
                            if (t.roleId == y.Id)
                            {
                                t.roleName = y.roleName;
                            }
                        });
                    });
                    List <Position> positionList = new PositionBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        positionList.ForEach(y =>
                        {
                            if (t.positionId == y.Id)
                            {
                                t.positionName = y.positionName;
                            }
                        });
                    });
                }
                string resJson = Common.Common.JsonSerialize(list);
                resJson = "{total:" + rows + ",root:" + resJson + "}";
                return(Content(resJson));
            }
            catch { }

            return(Content("{}"));
        }
Ejemplo n.º 3
0
        public void UpdateResponsible()
        {
            //Prueba la asigna un responsable a la donación

            //Creación del donador, un empleado (persona), la donación y el voluntario
            DonorBM  donor    = create_donor();
            PersonBM personBm = create_person();

            DonationStatusBM statusBm       = get_status(1);
            DonationBLL      donationBll    = new DonationBLL();
            DonationBM       donationBm     = new DonationBM(3, donor.donorId, statusBm, "Esta es una donación creada por un test.");
            ResultBM         donationResult = donationBll.SaveDonation(donationBm);

            BranchBLL branchBll    = new BranchBLL();
            ResultBM  branchResult = branchBll.GetBranch(1);

            VolunteerBLL volunteerBll   = new VolunteerBLL();
            VolunteerBM  volunteerBm    = new VolunteerBM(personBm, branchResult.GetValue <BranchBM>());
            ResultBM     volunterResult = volunteerBll.SaveVolunteer(volunteerBm);

            donationBm.volunteer = volunterResult.GetValue <VolunteerBM>();
            ResultBM updateResult = donationBll.UpdateDonation(donationBm);

            Assert.IsTrue(updateResult.IsValid(), "La operación debería ser válida.");

            donationResult = donationBll.GetDonation(updateResult.GetValue <DonationBM>().id);
            Assert.IsTrue(donationResult.IsValid(), "La operación debería ser válida.");
            Assert.IsNotNull(donationResult.GetValue(), "Deería haber devuelto una donación.");
            Assert.IsNotNull(donationResult.GetValue <DonationBM>().volunteer, "Deería haber devuelto un voluntario.");
            Assert.AreEqual(donationResult.GetValue <DonationBM>().volunteer.volunteerId, volunterResult.GetValue <VolunteerBM>().volunteerId, "Debería ser el mismo voluntario.");
        }
Ejemplo n.º 4
0
        public ActionResult GetEmployee()
        {
            try
            {
                int pageIndex = Convert.ToInt32(Request.QueryString["page"]);
                int pageSize = Convert.ToInt32(Request.QueryString["limit"]);
                string branchIds = Request.QueryString["id"];
                string[] _ids = branchIds.Split(',');
                int[] ids = Array.ConvertAll<string, int>(_ids, id =>
                {
                    return int.Parse(id);
                });
                EmployeeBLL eBll = new EmployeeBLL();
                int rows = 0;
                int totalPages = 0;
                List<Employee> list = eBll.LoadPagedEntitys(pageIndex, pageSize, out rows, out totalPages, t => ids.Contains(t.branchId), true, t => t.Id);
                if (list != null && list.Count > 0)
                {
                    List<Branch> branchList = new BranchBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        branchList.ForEach(y =>
                        {
                            if (t.branchId == y.Id)
                            {
                                t.branchName = y.branchName;
                            }
                        });
                    });
                    List<Role> roleList = new RoleBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        roleList.ForEach(y =>
                        {
                            if (t.roleId == y.Id)
                            {
                                t.roleName = y.roleName;
                            }
                        });
                    });
                    List<Position> positionList = new PositionBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        positionList.ForEach(y =>
                        {
                            if (t.positionId == y.Id)
                            {
                                t.positionName = y.positionName;
                            }
                        });
                    });
                }
                string resJson = Common.Common.JsonSerialize(list);
                resJson = "{total:" + rows + ",root:" + resJson + "}";
                return Content(resJson);
            }
            catch { }

            return Content("{}");
        }
Ejemplo n.º 5
0
        public ActionResult GetBranch()
        {
            BranchBLL         bBll       = new BranchBLL();
            List <Branch>     branchList = bBll.GetEntitys(t => t.sort);
            List <BranchTree> list       = new List <BranchTree>();

            foreach (Branch branch in branchList)
            {
                if (branch.parent == 0)
                {
                    BranchTree bTree = new BranchTree();
                    bTree.Id         = branch.Id;
                    bTree.branchName = branch.branchName;
                    bTree.parent     = branch.parent;
                    bTree.sort       = branch.sort;
                    bTree.telPhone   = branch.telPhone;
                    bTree.fax        = branch.fax;
                    bTree.expanded   = true;
                    bTree.leaf       = false;
                    bTree.children   = BranchEach(branchList, branch);
                    list.Add(bTree);
                }
            }
            string resJson = Common.Common.JsonSerialize(list);

            resJson  = "{'checked':false,'children':" + resJson;
            resJson += "}";
            return(Content(resJson));
        }
Ejemplo n.º 6
0
 public ActionResult GetBranch()
 {
     BranchBLL bBll = new BranchBLL();
     List<Branch> branchList = bBll.GetEntitys(t=>t.sort);
     List<BranchTree> list = new List<BranchTree>();
     foreach (Branch branch in branchList)
     {
         if (branch.parent == 0)
         {
             BranchTree bTree = new BranchTree();
             bTree.Id = branch.Id;
             bTree.branchName = branch.branchName;
             bTree.parent = branch.parent;
             bTree.sort = branch.sort;
             bTree.telPhone = branch.telPhone;
             bTree.fax = branch.fax;
             bTree.expanded = true;
             bTree.leaf = false;
             bTree.children = BranchEach(branchList, branch);
             list.Add(bTree);
         }
     }
     string resJson = Common.Common.JsonSerialize(list);
     resJson = "{'checked':false,'children':" + resJson;
     resJson += "}";
     return Content(resJson);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Set Grid Data source
        /// </summary>
        /// <param name="addRow"></param>
        /// <param name="deleteRow"></param>
        private void BindBranches()
        {
            BranchBLL objBranchBLL = new BranchBLL();
            int       BankID       = Convert.ToInt32(ViewState["BANK_ID"]);

            grdBankBranchs.DataSource = objBranchBLL.GetAllBranches(BankID);
            grdBankBranchs.DataBind();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Search banks data from the database and set filterd data to Grid Data source
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnClearSearch_Click(object sender, EventArgs e)
        {
            ClearDetails();

            BranchBLL objBranchBLL = new BranchBLL();

            grdBankBranchs.DataSource = objBranchBLL.GetAllBranches(Convert.ToInt32(ViewState["BANK_ID"]));
            grdBankBranchs.DataBind();
        }
Ejemplo n.º 9
0
 public ActionResult DeleteBranch()
 {
     string ids = Request.Form["ids"];
     BranchBLL bBll = new BranchBLL();
     if (bBll.DeletePhysicsById(ids))
     {
         return Content("{'success':'ok'}");
     }
     else
     {
         return Content("{}");
     }
 }
Ejemplo n.º 10
0
        public ActionResult DeleteBranch()
        {
            string    ids  = Request.Form["ids"];
            BranchBLL bBll = new BranchBLL();

            if (bBll.DeletePhysicsById(ids))
            {
                return(Content("{'success':'ok'}"));
            }
            else
            {
                return(Content("{}"));
            }
        }
Ejemplo n.º 11
0
        public void CreateVolunteer()
        {
            //Crea un donador
            PersonBM personBm = create_person();

            BranchBLL branchBll   = new BranchBLL();
            ResultBM  brancResult = branchBll.GetBranch(1);

            Assert.IsTrue(brancResult.IsValid(), "El donador debería existir.");

            VolunteerBLL volunteerBll   = new VolunteerBLL();
            VolunteerBM  volunteerBm    = new VolunteerBM(personBm, brancResult.GetValue <BranchBM>());
            ResultBM     volunterResult = volunteerBll.SaveVolunteer(volunteerBm);

            Assert.IsTrue(volunterResult.IsValid(), "El donador debería existir.");
            Assert.IsNotNull(volunterResult.GetValue(), "Debería existir el voluntario.");
            Assert.IsTrue(volunterResult.GetValue <VolunteerBM>().id > 0, "Debería existir el voluntario.");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// to bind the Bank Branches
        /// </summary>
        /// <param name="bankID"></param>
        protected void BindBankBranches(int bankID)
        {
            ListItem firstListItem = new ListItem(ddlBranch.Items[0].Text, ddlBranch.Items[0].Value);

            ddlBranch.Items.Clear();

            if (bankID > 0)
            {
                BranchBLL objBranchBLL = new BranchBLL();
                ddlBranch.DataSource = objBranchBLL.GetActiveBranches(bankID);

                ddlBranch.DataTextField  = "BRANCHNAME";
                ddlBranch.DataValueField = "BankBranchId";
                ddlBranch.DataBind();
            }

            ddlBranch.Items.Insert(0, firstListItem);
            ddlBranch.SelectedIndex = 0;
        }
Ejemplo n.º 13
0
        public ActionResult Save()
        {
            Branch branch = new Branch();

            try
            {
                string stated = Request.Form["stated"];
                if (stated == "add")
                {
                    branch.parent = Convert.ToInt32(Request.Form["Id"]);
                }
                else if (stated == "update")
                {
                    branch.parent = Convert.ToInt32(Request.Form["parent"]);
                    branch.Id     = Convert.ToInt32(Request.Form["Id"]);
                }
                branch.branchName = Request.Form["branchName"];
                branch.telPhone   = Request.Form["telPhone"];
                branch.fax        = Request.Form["fax"];
                branch.expanded   = Convert.ToInt32(Request.Form["expanded"]) == 0 ? false : true;
                branch.leaf       = Convert.ToInt32(Request.Form["leaf"]) == 0 ? false : true;
                branch.sort       = Convert.ToInt32(Request.Form["sort"]);

                BranchBLL bBll = new BranchBLL();
                if (stated == "add")
                {
                    if (bBll.AddEntity(branch))
                    {
                        return(Content("{'success':'ok'}"));
                    }
                }
                else if (stated == "update")
                {
                    if (bBll.ModifyEntity(branch))
                    {
                        return(Content("{'success':'ok'}"));
                    }
                }
            }
            catch { }
            return(Content("{}"));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Save and Update Data into Database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BranchBO objBranchBO = new BranchBO();

            objBranchBO.BankBranchId = Convert.ToInt32(ViewState["BankBranchId"]);
            objBranchBO.BankID       = Convert.ToInt32(ViewState["BANK_ID"]);
            objBranchBO.BranchName   = txtBranchName0.Text.Trim();
            objBranchBO.City         = txtCity0.Text.Trim();

            objBranchBO.SwiftCode = txtSwiftCode.Text.Trim();
            objBranchBO.BANKCODE  = txtBankCode.Text.Trim();

            BranchBLL objBranchBLL = new BranchBLL();
            string    AlertMessage = string.Empty;
            string    message      = string.Empty;

            if (objBranchBO.BankBranchId == 0)
            {
                objBranchBO.CreatedBy = Convert.ToInt32(Session["USER_ID"]);
                message = objBranchBLL.AddBranch(objBranchBO);
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data saved successfully";
                    ClearDetails();
                }
            }
            else
            {
                objBranchBO.UpdatedBy = Convert.ToInt32(Session["USER_ID"]);
                message = objBranchBLL.UpdateBranch(objBranchBO);
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data updated successfully";
                    ClearDetails();
                }
            }
            AlertMessage = "alert('" + message + "');";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);

            BindGrid();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Set edit mode for edit comand
        /// Delete data from the database for delete comand
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdBankBranchs_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditRow")
            {
                ViewState["BankBranchId"] = e.CommandArgument;
                BranchBO  objBranchBO  = new BranchBO();
                BranchBLL objBranchBLL = new BranchBLL();
                objBranchBO = objBranchBLL.GetBranchById(Convert.ToInt32(ViewState["BankBranchId"]));
                if (objBranchBO != null)
                {
                    ViewState["BankBranchId"] = objBranchBO.BankBranchId;
                    txtBranchName0.Text       = objBranchBO.BranchName;
                    txtCity0.Text             = objBranchBO.City;
                    txtSwiftCode.Text         = objBranchBO.SwiftCode;
                    txtBankCode.Text          = objBranchBO.BANKCODE;
                }
                SetUpdateMode(true);
            }

            else if (e.CommandName == "DeleteRow")
            {
                string    message      = string.Empty;
                int       Branch       = Convert.ToInt32(e.CommandArgument);
                BranchBLL objBranchBLL = new BranchBLL();
                message = objBranchBLL.DeleteBranch(Convert.ToInt32(e.CommandArgument));
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    ClearDetails();
                }
                message = "Data deleted successfully";


                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }

                BindGrid();
            }
        }
Ejemplo n.º 16
0
        public static void InitDB()
        {
            if (IsInited)
            {
                return;
            }
            UserBLL.Add(new Model.DBUser()
            {
                OpenID = "0001", BranchID = "001", Name = "唐赞飞", NickName = "飞", IsManager = true
            });
            UserBLL.Add(new Model.DBUser()
            {
                OpenID = "0002", BranchID = "001", Name = "唐观文", NickName = "唐观文", IsManager = true
            });
            UserBLL.Add(new Model.DBUser()
            {
                OpenID = "0003", BranchID = "001", Name = "欧阳石光", NickName = "时光", IsManager = false
            });

            BranchBLL.Add(new Model.DBBranch()
            {
                ID = "001", MasterID = "0002", Name = "县委组织部第一支部"
            });

            PointBLL.Add(new Model.DBPoint()
            {
                ID = "001", Name = "县委组织部会议室", QrCode = "XWZZBHYS", WifiName = "556", WifiMac = "FF-FF-FF-FF"
            });
            PointBLL.Add(new Model.DBPoint()
            {
                ID = "002", Name = "翡翠湾社区", QrCode = "FCWSQ", WifiName = "TPLink368E", WifiMac = "FF-FF-FF-FF"
            });
            PointBLL.Add(new Model.DBPoint()
            {
                ID = "003", Name = "凯旋城", QrCode = "KXC", WifiName = "TPLink368E", WifiMac = "FF-FF-FF-FF"
            });
            IsInited = true;
        }
Ejemplo n.º 17
0
        public ActionResult Save()
        {
            Branch branch = new Branch();
            try
            {
                string stated = Request.Form["stated"];
                if (stated == "add")
                    branch.parent = Convert.ToInt32(Request.Form["Id"]);
                else if (stated == "update")
                {
                    branch.parent = Convert.ToInt32(Request.Form["parent"]);
                    branch.Id = Convert.ToInt32(Request.Form["Id"]);
                }
                branch.branchName = Request.Form["branchName"];
                branch.telPhone = Request.Form["telPhone"];
                branch.fax = Request.Form["fax"];
                branch.expanded = Convert.ToInt32(Request.Form["expanded"]) == 0 ? false : true;
                branch.leaf = Convert.ToInt32(Request.Form["leaf"]) == 0 ? false : true;
                branch.sort = Convert.ToInt32(Request.Form["sort"]);

                BranchBLL bBll = new BranchBLL();
                if (stated == "add")
                {
                    if (bBll.AddEntity(branch))
                    {
                        return Content("{'success':'ok'}");
                    }
                }
                else if (stated == "update")
                {
                    if (bBll.ModifyEntity(branch))
                    {
                        return Content("{'success':'ok'}");
                    }
                }
            }
            catch { }
            return Content("{}");
        }