Esempio n. 1
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            if (inputCheck())
            {
                DataRow sessionDr  = Session["supplierDr"] as DataRow;
                string  supplierId = sessionDr["supplierId"].ToString().Trim();

                string smn = txtName.Text.ToString().Trim();
                string smd = txtDep.Text.ToString().Trim();
                string smt = txtTitle.Text.ToString().Trim();
                string smc = txtContact.Text.ToString().Trim();
                string sme = txtEmail.Text.ToString().Trim();
                string sId = supplierId;

                #region dataset
                DataSet dataSet        = new DataSet();
                DataRow supplierManRow = null;

                DataColumn colSupplierManName    = new DataColumn("supplierManName", System.Type.GetType("System.String"));
                DataColumn colSupplierManDep     = new DataColumn("supplierManDepart", System.Type.GetType("System.String"));
                DataColumn colSupplierManTitle   = new DataColumn("supplierManTitle", System.Type.GetType("System.String"));
                DataColumn colSupplierManContact = new DataColumn("supplierManContact", System.Type.GetType("System.String"));
                DataColumn colSupplierManEmail   = new DataColumn("supplierManEmail", System.Type.GetType("System.String"));
                DataColumn colSupplierId         = new DataColumn("supplierId", System.Type.GetType("System.String"));

                DataTable supplierManTable = new DataTable("tbl_supplier_manager");

                supplierManTable.Columns.Add(colSupplierManName);
                supplierManTable.Columns.Add(colSupplierManDep);
                supplierManTable.Columns.Add(colSupplierManTitle);
                supplierManTable.Columns.Add(colSupplierManContact);
                supplierManTable.Columns.Add(colSupplierManEmail);
                supplierManTable.Columns.Add(colSupplierId);

                supplierManRow = supplierManTable.NewRow();
                supplierManRow["supplierManName"]    = smn;
                supplierManRow["supplierManDepart"]  = smd;
                supplierManRow["supplierManTitle"]   = smt;
                supplierManRow["supplierManContact"] = smc;
                supplierManRow["supplierManEmail"]   = sme;
                supplierManRow["supplierId"]         = sId;
                supplierManTable.Rows.Add(supplierManRow);

                dataSet.Tables.Add(supplierManTable);
                #endregion

                SupplierManProcess smp = new SupplierManProcess(dataSet);

                smp.Add();

                string continueUrl = "~/Main/custInfoManager/supplierManager/supplierEditing.aspx";

                Response.Redirect(continueUrl);
            }
        }
Esempio n. 2
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();
            }
        }
Esempio n. 3
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;
        }
Esempio n. 4
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;
            }
        }