Esempio n. 1
0
        //private void BindMerchandisingGroupList()
        //{
        //    DropDownListMerchandisingGroupList.DataSource = SPARInsightManagement.Web.Code.InsightSupplierMerchandising.GetMerchandisingGroupList();
        //    DropDownListMerchandisingGroupList.DataTextField = "MerchandisingGroup";
        //    DropDownListMerchandisingGroupList.DataValueField = "GroupId";
        //    DropDownListMerchandisingGroupList.DataBind();

        //    if (DropDownListMerchandisingGroupList.Items.Count > 1)
        //    {
        //        DropDownListMerchandisingGroupList.Items.Insert(0, new ListItem("Please select", "0"));
        //    }
        //}

        private void BindGridViewResultList()
        {
            GridViewResultSupplierGroup.DataSource = null;
            GridViewResultSupplierGroup.DataBind();

            GridViewResultSupplier.DataSource = null;
            GridViewResultSupplier.DataBind();

            GridViewResultCustom.DataSource = null;
            GridViewResultCustom.DataBind();

            switch (this.supplierTypeId)
            {
            case 1:     //Supplier Group
                GridViewResultSupplierGroup.DataSource = InsightSupplierMerchandising.GetSupplierMerchandisingListBySupplierGroup(Convert.ToInt32(DropDownListSupplierParentList.SelectedValue), this.insightSupplierId);
                GridViewResultSupplierGroup.DataBind();
                ButtonSave.Visible = GridViewResultSupplierGroup.Rows.Count > 0;
                break;

            case 2:     //Supplier
                GridViewResultSupplier.DataSource = InsightSupplierMerchandising.GetSupplierMerchandisingListBySupplierId(Convert.ToInt32(DropDownListSupplierList.SelectedValue), this.insightSupplierId);
                GridViewResultSupplier.DataBind();
                ButtonSave.Visible = GridViewResultSupplier.Rows.Count > 0;

                BindDropDownListSupplierListDiscontinuedColour();
                break;

            case 3:     //Custom
                GridViewResultCustom.DataSource = InsightSupplierMerchandising.GetSupplierMerchandisingListByCustom(/*Convert.ToInt32(DropDownListMerchandisingGroupList.SelectedValue)*/ this.insightSupplierId);
                GridViewResultCustom.DataBind();
                ButtonSave.Visible = GridViewResultCustom.Rows.Count > 0;
                break;
            }
        }
        protected void GridViewResult_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName.ToLower())
                {
                case "removeinsightsupplier":
                {
                    int insightSupplierId = Convert.ToInt32(e.CommandArgument);

                    InsightSupplierCustomHeader.DeleteInsightSupplierCustomHeaderByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactDistributionLink.DeleteInsightSupplierContactDistributionLinkByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactDistributionOption.DeleteInsightSupplierContactDistributionOptionByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactDistributionModel.DeleteInsightSupplierContactDistributionModelByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactLicense.DeleteInsightSupplierContactLicenseByInsightSupplierId(insightSupplierId);
                    InsightSupplierContactLink.DeleteInsightSupplierContactLinkByInsightSupplierId(insightSupplierId);
                    InsightSupplierMerchandising.DeleteInsightSupplierMerchandisingByInsightSupplierId(insightSupplierId);
                    InsightSupplierMerchSupplierLink.DeleteInsightSupplierMerchSupplierLinkByInsightSupplierId(insightSupplierId);
                    InsightSupplier.DeleteInsightSupplierByInsightSupplierId(insightSupplierId);

                    BindGridViewResultDefault();

                    break;
                }
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
            }
        }
        private void BindInsightSupplier()
        {
            try
            {
                InsightSupplier insightSupplier = InsightSupplier.GetInsightSupplierByInsightSupplierId(Convert.ToInt32(ViewState["InsightSupplierId"]));
                TextBoxSupplierName.Text     = insightSupplier.SupplierName;
                TextBoxCustomSupplierId.Text = InsightSupplierMerchandising.GetCustomSupplierByInsightSupplierId(Convert.ToInt32(ViewState["InsightSupplierId"])).CustomSupplierId;

                DropDownListModelType.ClearSelection();
                DropDownListModelType.Items.FindByValue(insightSupplier.ModelTypeId.ToString()).Selected = true;
                BindModelTypeSecurity();

                CloseSupplierAuthorization();
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
            catch (Exception exception)
            {
                LabelError.Text   += (exception.Message + "<br />");
                PanelError.Visible = true;
            }
        }
        protected void GridViewResult_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            InsightSupplierMerchandising ism = (InsightSupplierMerchandising)e.Row.DataItem;

            if (ism != null && ism.isSelected)
            {
                e.Row.BackColor = System.Drawing.Color.LightGray;
            }
        }
        //private void SaveInsightSupplieMerchSupplierParent(int insightSupplierId)
        //{
        //    InsightSupplierMerchSupplierLink iSMSL = new InsightSupplierMerchSupplierLink();
        //    iSMSL.InsightSupplierId = insightSupplierId;
        //    iSMSL.SupplierParentId = Convert.ToInt32(DropDownListSupplierParentList.SelectedValue);
        //    iSMSL.ModifiedUser = Context.User.Identity.GetUserName();

        //    iSMSL.Save();
        //}

        private void SaveSupplier()
        {
            //if (Page.IsValid)
            //{
            try
            {
                LabelError.Text = "";
                string modifiedUser = Context.User.Identity.GetUserName();

                InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising();
                InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierIdAndSupplierId(Convert.ToInt32(ViewState["InsightSupplierId"]), Convert.ToInt32(ViewState["SupplierId"]));

                foreach (GridViewRow gridViewRow in GridViewResultSupplier.Rows)
                {
                    HiddenField hiddenFieldSupplierSupplierId         = (HiddenField)gridViewRow.Cells[0].FindControl("HiddenFieldSupplierSupplierId");
                    HiddenField hiddenFieldSupplierGroupId            = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldSupplierGroupId");
                    HiddenField hiddenFieldSupplierMerchId            = (HiddenField)gridViewRow.Cells[2].FindControl("HiddenFieldSupplierMerchId");
                    CheckBox    checkBoxSupplierMerchandisingSelected = (CheckBox)gridViewRow.Cells[4].FindControl("CheckBoxSupplierMerchandisingSelected");

                    if (checkBoxSupplierMerchandisingSelected.Checked)
                    {
                        insightSupplierMerchandising.InsightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"]);
                        insightSupplierMerchandising.SupplierParentId  = 0;
                        insightSupplierMerchandising.SupplierId        = Convert.ToInt32(hiddenFieldSupplierSupplierId.Value);
                        //insightSupplierMerchandising.CustomSupplierId = TextBoxCustomSupplierId.Text;
                        insightSupplierMerchandising.GroupId      = Convert.ToInt32(hiddenFieldSupplierGroupId.Value);
                        insightSupplierMerchandising.MerchId      = Convert.ToInt32(hiddenFieldSupplierMerchId.Value);
                        insightSupplierMerchandising.IsIncluded   = 1;//(RadioButtonInclusion.Checked == true) ? 1 : 2;
                        insightSupplierMerchandising.ModifiedUser = modifiedUser;
                        insightSupplierMerchandising.Save();
                    }
                    else
                    {
                        insightSupplierMerchandising.InsightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"]);
                        insightSupplierMerchandising.SupplierParentId  = 0;
                        insightSupplierMerchandising.SupplierId        = Convert.ToInt32(hiddenFieldSupplierSupplierId.Value);
                        //insightSupplierMerchandising.CustomSupplierId = "Reset";
                        insightSupplierMerchandising.GroupId      = Convert.ToInt32(hiddenFieldSupplierGroupId.Value);
                        insightSupplierMerchandising.MerchId      = Convert.ToInt32(hiddenFieldSupplierMerchId.Value);
                        insightSupplierMerchandising.IsIncluded   = 2;//(RadioButtonInclusion.Checked == true) ? 1 : 2;
                        insightSupplierMerchandising.ModifiedUser = modifiedUser;
                        insightSupplierMerchandising.Save();
                    }
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
            //}
        }
        private void BindViewAuthorization(int supplierId)
        {
            if (supplierId > 0)
            {
                ViewState["SupplierId"] = supplierId;
            }

            GridViewResult.DataSource = InsightSupplierMerchandising.GetSupplierAuthorizationBySupplierId(Convert.ToInt32(ViewState["SupplierId"]));
            GridViewResult.DataBind();
            PanelSupplierAuthorization.Visible = true;
        }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            //if (Page.IsValid)
            //{
            try
            {
                LabelError.Text = "";
                string modifiedUser = Context.User.Identity.GetUserName();

                InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising();
                InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierId(this.insightSupplierId);
                HiddenField hiddenFieldCustomSupplierId = null;

                foreach (GridViewRow gridViewRow in GridViewResult.Rows)
                {
                    hiddenFieldCustomSupplierId = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldCustomSupplierId");
                    HiddenField hiddenFieldSupplierGroupId          = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldCustomGroupId");
                    HiddenField hiddenFieldSupplierMerchId          = (HiddenField)gridViewRow.Cells[2].FindControl("HiddenFieldCustomMerchId");
                    CheckBox    checkBoxCustomMerchandisingSelected = (CheckBox)gridViewRow.Cells[4].FindControl("CheckBoxCustomMerchandisingSelected");

                    if (checkBoxCustomMerchandisingSelected.Checked)
                    {
                        insightSupplierMerchandising.InsightSupplierId = this.insightSupplierId;
                        insightSupplierMerchandising.SupplierParentId  = 0;
                        insightSupplierMerchandising.SupplierId        = 0;
                        //insightSupplierMerchandising.CustomSupplierId = TextBoxCustomSupplierId.Text;
                        insightSupplierMerchandising.GroupId      = Convert.ToInt32(hiddenFieldSupplierGroupId.Value);
                        insightSupplierMerchandising.MerchId      = Convert.ToInt32(hiddenFieldSupplierMerchId.Value);
                        insightSupplierMerchandising.IsIncluded   = 1; //(RadioButtonInclusion.Checked == true) ? 1 : 2;
                        insightSupplierMerchandising.IsCustom     = 2; // 1 - Insight Supplier with Supplier; 2 - Insight Supplier with Custom Supplier
                        insightSupplierMerchandising.ModifiedUser = modifiedUser;
                        insightSupplierMerchandising.Save();
                    }
                }

                InsightSupplierMerchandising.UpdateInsightSupplierMerchandisingCustomSupplierIdByInsightSupplierId(this.insightSupplierId, (hiddenFieldCustomSupplierId.Value.Length > 0) ? hiddenFieldCustomSupplierId.Value : "0");

                LabelError.Text    = "Save Successful.";
                PanelError.Visible = true;

                BindGridViewResult();
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
            //}
        }
Esempio n. 8
0
        private void SaveSupplierGroup()
        {
            if (Page.IsValid)
            {
                try
                {
                    LabelError.Text = "";
                    string modifiedUser     = Context.User.Identity.GetUserName();
                    string customSupplierId = "100" + this.insightSupplierId.ToString();

                    InsightSupplierMerchandising insightSupplierMerchandising = new InsightSupplierMerchandising();
                    //InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierId(this.insightSupplierId);
                    InsightSupplier.DeleteInsightSupplierMerchandisingByInsightSupplierParentId(this.insightSupplierId, Convert.ToInt32(DropDownListSupplierParentList.SelectedValue));

                    foreach (GridViewRow gridViewRow in GridViewResultSupplierGroup.Rows)
                    {
                        HiddenField hiddenFieldGroupSupplierParentId   = (HiddenField)gridViewRow.Cells[0].FindControl("HiddenFieldGroupSupplierParentId");
                        HiddenField hiddenFieldGroupSupplierId         = (HiddenField)gridViewRow.Cells[1].FindControl("HiddenFieldGroupSupplierId");
                        HiddenField HiddenFieldGroupGroupId            = (HiddenField)gridViewRow.Cells[2].FindControl("HiddenFieldGroupGroupId");
                        HiddenField hiddenFieldGroupMerchId            = (HiddenField)gridViewRow.Cells[3].FindControl("HiddenFieldGroupMerchId");
                        CheckBox    checkBoxGroupMerchandisingSelected = (CheckBox)gridViewRow.Cells[5].FindControl("CheckBoxGroupMerchandisingSelected");

                        if (checkBoxGroupMerchandisingSelected.Checked)
                        {
                            insightSupplierMerchandising.InsightSupplierId = insightSupplierId;
                            insightSupplierMerchandising.SupplierParentId  = Convert.ToInt32(hiddenFieldGroupSupplierParentId.Value);
                            insightSupplierMerchandising.SupplierId        = Convert.ToInt32(hiddenFieldGroupSupplierId.Value);
                            insightSupplierMerchandising.CustomSupplierId  = customSupplierId;
                            insightSupplierMerchandising.GroupId           = Convert.ToInt32(HiddenFieldGroupGroupId.Value);
                            insightSupplierMerchandising.MerchId           = Convert.ToInt32(hiddenFieldGroupMerchId.Value);
                            insightSupplierMerchandising.ModifiedUser      = modifiedUser;
                            insightSupplierMerchandising.Save();
                        }
                    }
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                    PanelError.Visible = true;
                }
            }
        }
        private void BindSupplierMerchandisingGridView()
        {
            InsightSupplierMerchandising ism = InsightSupplierMerchandising.GetInsightSupplierMerchandisingBySupplierId(Convert.ToInt32(ViewState["SupplierId"]), Convert.ToInt32(ViewState["InsightSupplierId"]));

            //if (ism.IsIncluded == 1)
            //{
            //    RadioButtonInclusion.Checked = true;
            //    RadioButtonExclusion.Checked = false;
            //}
            //else
            //{
            //    RadioButtonInclusion.Checked = false;
            //    RadioButtonExclusion.Checked = true;
            //}


            GridViewResultSupplier.DataSource = InsightSupplierMerchandising.GetSupplierMerchandisingListBySupplierId(Convert.ToInt32(ViewState["SupplierId"]), Convert.ToInt32(ViewState["InsightSupplierId"]));
            GridViewResultSupplier.DataBind();

            PanelSupplierMerchandising.Visible = GridViewResultSupplier.Rows.Count > 0;
        }
 public void BindGridViewResult()
 {
     GridViewResult.DataSource = InsightSupplierMerchandising.GetSupplierMerchandisingListCustom(this.insightSupplierId);
     GridViewResult.DataBind();
 }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            //if (Page.IsValid)
            //{
            bool hasError = false;

            LabelError.Text    = "";
            PanelError.Visible = false;

            if (TextBoxSupplierName.Text.Length == 0)
            {
                LabelError.Text += " Name is required.";
                hasError         = true;
            }

            if (Convert.ToInt32(DropDownListModelType.SelectedValue) == 0)
            {
                LabelError.Text += " Model Type is required.";
                hasError         = true;
            }

            if (hasError == true)
            {
                PanelError.Visible = true;
                return;
            }

            InsightSupplier insightSupplier = new InsightSupplier();

            insightSupplier.InsightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"]);
            insightSupplier.SupplierName      = TextBoxSupplierName.Text;
            insightSupplier.ModelTypeId       = Convert.ToInt32(DropDownListModelType.SelectedValue);
            insightSupplier.ModifiedUser      = Context.User.Identity.GetUserName();

            try
            {
                insightSupplier.Save();
                int insightSupplierId = insightSupplier.InsightSupplierId;

                if (DropDownListModelType.SelectedValue != "4")
                {
                    SaveSupplier();
                }

                InsightSupplierMerchandising.UpdateInsightSupplierMerchandisingCustomSupplierIdByInsightSupplierId(insightSupplierId, (TextBoxCustomSupplierId.Text.Length > 0) ? TextBoxCustomSupplierId.Text : "0");

                Button clickedButton = (Button)sender;
                switch (clickedButton.ID)
                {
                case "ButtonSave":
                    CloseSupplierAuthorization();
                    CloseSupplierMerchandisingGridView();

                    if (Convert.ToInt32(DropDownListModelType.SelectedValue) == 4)
                    {
                        ViewState["InsightSupplierId"] = insightSupplierId;
                        BindModelTypeSecurity();
                    }

                    //Response.Redirect(String.Format("InsightSupplierList.aspx?SupplierName={0}", insightSupplier.SupplierName));
                    break;

                case "ButtonSaveNew":
                    Response.Redirect("InsightSupplierHeaderEdit.aspx");
                    break;
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />");
                }
            }
            //}
        }