Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(null == Session["totleAuthority"]))
            {
                AuthAttributes usrAuthAttr = (AuthAttributes)Session["totleAuthority"];

                bool flag = usrAuthAttr.HasOneFlag(AuthAttributes.custManager);
                if (!flag)
                {
                    Response.Redirect("~/Main/NoAuthority.aspx");
                }
            }
            else
            {
                string url = Request.FilePath;
                Session["backUrl"] = url;
                Response.Redirect("~/Account/Login.aspx");
            }

            if (null == Session["supplierDr"])
            {
                Response.Redirect("~/Main/custInfoManager/supplierManager/supplierEdit.aspx");
            }

            if (!IsPostBack)
            {
                DataRow sessionDr = Session["supplierDr"] as DataRow;

                lblSupplierName.Text = sessionDr["supplierName"].ToString();
                lblSupplierAddr.Text = sessionDr["supplierAddress"].ToString();

                string supplierId = sessionDr["supplierId"].ToString();

                DataSet            MyDst  = new DataSet();
                SupplierManProcess myView = new SupplierManProcess(MyDst);
                myView.SupplierId = supplierId;

                myView.RealSupplierManView();
                DataTable taskTable = myView.MyDst.Tables["tbl_supplier_manager"];

                Session["SupplierManProcess"] = myView;
                Session["dtSources"]          = taskTable;


                supplierManGV.DataSource = Session["dtSources"];
                supplierManGV.DataBind();
            }
        }
Beispiel #2
0
        protected void btnAcceptDel_Click(object sender, EventArgs e)
        {
            int       dataIndex = supplierManGV.SelectedRow.DataItemIndex;
            DataTable dt        = (DataTable)Session["dtSources"];
            string    manId     = dt.DefaultView[dataIndex].Row["supplierManId"].ToString();

            Button btn = null;

            btn         = (supplierManGV.SelectedRow.FindControl("btnUpdate") as Button);
            btn.Visible = false;
            btn         = (supplierManGV.SelectedRow.FindControl("btnCancle") as Button);
            btn.Visible = false;
            btn         = (supplierManGV.SelectedRow.FindControl("btnDel") as Button);
            btn.Visible = false;
            btn         = sender as Button;
            btn.Visible = false;
            btn         = btnDelCancel;
            btn.Visible = false;

            SupplierManProcess smp = Session["SupplierManProcess"] as SupplierManProcess;

            smp.SupplierManDel(manId);

            smp.RealSupplierManView();

            DataTable taskTable = smp.MyDst.Tables["tbl_supplier_manager"];

            Session["dtSources"]     = smp.MyDst.Tables["tbl_supplier_manager"] as DataTable;
            supplierManGV.DataSource = Session["dtSources"];

            supplierManGV.SelectedIndex = -1;
            supplierManGV.EditIndex     = -1;
            supplierManGV.DataBind();

            supplierManGV.Enabled = true;
            btnAdd.Visible        = true;
        }
Beispiel #3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            int index = supplierManGV.SelectedIndex;

            int       dataIndex = supplierManGV.Rows[index].DataItemIndex;
            DataTable dt        = (DataTable)Session["dtSources"];

            GridViewRow row = supplierManGV.Rows[index];
            TextBox     tbSupplierManName   = row.Cells[1].Controls[0] as TextBox;
            string      newSupplierManName  = tbSupplierManName.Text.ToString().Trim();
            TextBox     tbSupplierManCont   = row.Cells[2].Controls[0] as TextBox;
            string      newSupplierManCont  = tbSupplierManCont.Text.ToString().Trim();
            TextBox     tbSupplierManEmail  = row.Cells[3].Controls[0] as TextBox;
            string      newSupplierManEmail = tbSupplierManEmail.Text.ToString().Trim();
            TextBox     tbSupplierManDep    = row.Cells[4].Controls[0] as TextBox;
            string      newSupplierManDep   = tbSupplierManDep.Text.ToString().Trim();
            TextBox     tbSupplierManTitle  = row.Cells[5].Controls[0] as TextBox;
            string      newSupplierManTitle = tbSupplierManTitle.Text.ToString().Trim();

            string strNameCheck  = newSupplierManName;
            string strContCheck  = newSupplierManCont;
            string strEmailCheck = newSupplierManEmail;
            string strDepCheck   = newSupplierManDep;
            string strTitleCheck = newSupplierManTitle;

            newSupplierManName  = input_check(strNameCheck);//, dtCheck);
            newSupplierManCont  = input_check(strContCheck);
            newSupplierManEmail = input_check(strEmailCheck);
            newSupplierManDep   = input_check(strDepCheck);
            newSupplierManTitle = input_check(strTitleCheck);

            bool checkFlag = true;

            checkFlag = checkFlag && newSupplierManName.Equals(strNameCheck);
            checkFlag = checkFlag && newSupplierManCont.Equals(strContCheck);
            checkFlag = checkFlag && newSupplierManEmail.Equals(strEmailCheck);
            checkFlag = checkFlag && newSupplierManDep.Equals(strDepCheck);
            checkFlag = checkFlag && newSupplierManTitle.Equals(strTitleCheck);

            if (true == checkFlag)
            {
                int supplierManId = int.Parse(dt.DefaultView[dataIndex].Row["supplierManId"].ToString());

                SupplierManProcess smp = Session["SupplierManProcess"] as SupplierManProcess;

                smp.SupplierManUpdate(supplierManId, newSupplierManName, newSupplierManCont, newSupplierManEmail, newSupplierManDep, newSupplierManTitle);

                smp.RealSupplierManView();

                DataTable taskTable = smp.MyDst.Tables["tbl_supplier_manager"];
                Session["dtSources"] = smp.MyDst.Tables["tbl_supplier_manager"] as DataTable;

                Button btn = null;
                btn         = sender as Button;
                btn.Visible = false;
                btn         = (supplierManGV.SelectedRow.FindControl("btnCancle") as Button);
                btn.Visible = false;
                btn         = (supplierManGV.SelectedRow.FindControl("btnDel") as Button);
                btn.Visible = false;
                btn         = btnDelCancel;
                btn.Visible = false;
                btn         = btnAcceptDel;
                btn.Visible = false;

                supplierManGV.SelectedIndex = -1;
                supplierManGV.EditIndex     = -1;

                supplierManGV.DataSource = Session["dtSources"];//["dtSources"] as DataTable;
                supplierManGV.DataBind();

                btnAdd.Visible = true;
            }
            else
            {
                tbSupplierManName.Text  = newSupplierManName;
                tbSupplierManCont.Text  = newSupplierManCont;
                tbSupplierManEmail.Text = newSupplierManEmail;
                tbSupplierManDep.Text   = newSupplierManDep;
                tbSupplierManTitle.Text = newSupplierManTitle;

                supplierManGV.SelectedIndex = index;
                supplierManGV.EditIndex     = index;
            }
        }