Ejemplo n.º 1
0
        /// <summary>
        /// Populate the controls.
        /// </summary>
        private void PopulateControls()
        {
            //Header Text
            this.litHeaderText.Text    = ((this.QueryID > 0) ? "Edit " : "New ") + this.ActivePage.Heading;
            Session["CombinedFabrics"] = new List <KeyValuePair <int, KeyValuePair <int, string> > >();

            //Fabric Types
            ddlFabricCodeType.Items.Clear();
            ddlFabricCodeType.Items.Add(new ListItem("Select a Type", "-1"));
            int fabricCodeType = 0;

            foreach (FabricType type in Enum.GetValues(typeof(FabricType)))
            {
                ddlFabricCodeType.Items.Add(new ListItem(type.ToString(), fabricCodeType++.ToString()));
            }

            FabricCodeBO objFabric = new FabricCodeBO();

            if (this.QueryID < 1)
            {
                objFabric.IsActive = true;
            }
            List <FabricCodeBO> lstFabricCodes = objFabric.SearchObjects();

            Session["ListFabricCodes"] = lstFabricCodes;

            this.PopulateFabricDataGrid(0, 0);
        }
        protected void btnAddFabric_Click(object sender, EventArgs e)
        {
            ViewState["populateaddNewNote"] = false;

            int qid = int.Parse(this.ddlFabric.SelectedValue); //int.Parse(((System.Web.UI.WebControls.LinkButton)(sender)).Attributes["qid"].ToString());

            if (qid > 0)
            {
                // Hide selected fabric
                //PRW ((System.Web.UI.WebControls.LinkButton)sender).Parent.Parent.Visible = false;

                FabricCodeBO objFabric = new FabricCodeBO(this.ObjContext);
                objFabric.ID = qid;
                objFabric.GetObject();

                // Add selected fabric
                this.FabricCodesWhereThisIsPattern.Add(objFabric);

                // Populate active pattern fabrics
                this.PopulatePatternFabrics();
                this.ProcessForm(qid);
                this.PopulatePatternFabrics();
                this.PopulateFabrics();
            }

            ViewState["PopulatePatern"] = false;
            ViewState["PopulateFabric"] = false;
        }
Ejemplo n.º 3
0
        protected void dgFabrics_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DataGridItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is FabricCodeBO)
            {
                FabricCodeBO objFabric = (FabricCodeBO)item.DataItem;

                LinkButton btnSelectFabric = (LinkButton)item.FindControl("btnSelectFabric");
                btnSelectFabric.Attributes.Add("qid", objFabric.ID.ToString());
                btnSelectFabric.Attributes.Add("index", item.ItemIndex.ToString());
            }
        }
Ejemplo n.º 4
0
        protected void dgSelectedFabrics_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DataGridItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is FabricCodeBO)
            {
                FabricCodeBO objFabric = (FabricCodeBO)item.DataItem;
                PriceBO      objPrice  = (new PriceBO()).GetAllObject().SingleOrDefault(o => o.Pattern == int.Parse(this.hdnPattern.Value) && o.FabricCode == objFabric.ID);

                Literal litSetCost = (Literal)item.FindControl("litSetCost");
                litSetCost.Text = "Set cost for all levels";

                HtmlInputText txtSetCost = (HtmlInputText)item.FindControl("txtSetCost");

                HtmlControl olPriceTable = (HtmlControl)item.FindControl("olPriceTable");
                HtmlButton  btnApply     = (HtmlButton)item.FindControl("btnApply");
                btnApply.Attributes.Add("table", olPriceTable.ClientID);

                HtmlButton btnUpdate = (HtmlButton)item.FindControl("btnUpdate");
                btnUpdate.Attributes.Add("qid", objFabric.ID.ToString());
                btnUpdate.InnerText = (objPrice != null) ? "Update" : "Add";

                HtmlButton btnDelete = (HtmlButton)item.FindControl("btnDelete");
                btnDelete.Attributes.Add("qid", objFabric.ID.ToString());

                Repeater rptPriceLevelCost = (Repeater)item.FindControl("rptPriceLevelCost");
                if (objPrice != null) // Update
                {
                    decimal factoryCost = objPrice.PriceLevelCostsWhereThisIsPrice.Select(o => o.FactoryCost).Aggregate((x, y) => x + y);
                    isEnableIndimanCost = (factoryCost > 0);

                    litSetCost.Visible = isEnableIndimanCost;
                    txtSetCost.Visible = isEnableIndimanCost;
                    btnApply.Visible   = isEnableIndimanCost;
                    btnUpdate.Visible  = isEnableIndimanCost;

                    rptPriceLevelCost.DataSource = objPrice.PriceLevelCostsWhereThisIsPrice;
                }
                else // Add New
                {
                    litSetCost.Visible = false;
                    txtSetCost.Visible = false;
                    btnApply.Visible   = false;

                    List <DistributorPriceMarkupBO> lstPriceMarkups = (new DistributorPriceMarkupBO()).GetAllObject().Where(o => (int)o.Distributor == int.Parse(this.ddlDistributors.SelectedValue.Trim())).ToList();
                    rptPriceLevelCost.DataSource = lstPriceMarkups;
                }
                rptPriceLevelCost.DataBind();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Process the page data.
        /// </summary>
        private void ProcessForm(int fabricID, bool isDelete)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    FabricCodeBO objFabricCode = new FabricCodeBO(this.ObjContext);
                    if (fabricID > 0)
                    {
                        objFabricCode.ID = fabricID;
                        objFabricCode.GetObject();
                    }

                    if (isDelete)
                    {
                        objFabricCode.Delete();
                    }
                    else
                    {
                        objFabricCode.Code     = this.txtFabricCode.Text;
                        objFabricCode.Name     = this.txtCombinedName.Text;
                        objFabricCode.NickName = (!String.IsNullOrEmpty(this.txtCombinedNickName.Text)) ? this.txtCombinedNickName.Text : string.Empty;
                        objFabricCode.IsActive = (this.chkCombinedIsActive.Checked) ? true : false;

                        objFabricCode.IsLiningFabric = false;
                        objFabricCode.IsPure         = false;
                        objFabricCode.Country        = 14;

                        if (fabricID == 0)
                        {
                            objFabricCode.Add();
                        }
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                // Log the error
                IndicoLogging.log.Error("Error occured while Saving Fabric", ex);
            }
        }
Ejemplo n.º 6
0
        private void PopulateFilteredFabrics(bool isLining)
        {
            FabricCodeBO objFabric = new FabricCodeBO();

            objFabric.IsActive       = true;
            objFabric.IsPure         = true;
            objFabric.IsLiningFabric = isLining;

            Dictionary <int, string> filteredfabrics = objFabric.SearchObjects().AsQueryable().OrderBy(o => o.Name).ToList().Select(o => new { Key = o.ID, Value = (o.Code + " - " + o.NickName) }).ToDictionary(o => o.Key, o => o.Value);
            Dictionary <int, string> fdicFabrics     = new Dictionary <int, string>();

            fdicFabrics.Add(0, "Please select or type...");
            foreach (KeyValuePair <int, string> item in filteredfabrics)
            {
                fdicFabrics.Add(item.Key, item.Value);
            }

            this.ddlAddFabrics.DataSource     = fdicFabrics;
            this.ddlAddFabrics.DataTextField  = "Value";
            this.ddlAddFabrics.DataValueField = "Key";
            this.ddlAddFabrics.DataBind();
        }
Ejemplo n.º 7
0
        protected void dgvAddEditFabrics_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DataGridItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is KeyValuePair <int, KeyValuePair <int, string> > ) // KeyValuePair<Tuple<int, int>, int>)
            {
                KeyValuePair <int, KeyValuePair <int, string> > kv = (KeyValuePair <int, KeyValuePair <int, string> >)item.DataItem;

                Literal litID             = (Literal)item.FindControl("litID");
                Literal litFabricTypeID   = (Literal)item.FindControl("litFabricTypeID");
                Literal litFabricType     = (Literal)item.FindControl("litFabricType");
                Literal litCode           = (Literal)item.FindControl("litCode");
                Literal litFabricNickName = (Literal)item.FindControl("litFabricNickName");
                Literal litFabricSupplier = (Literal)item.FindControl("litFabricSupplier");
                TextBox txtWhere          = (TextBox)item.FindControl("txtWhere");

                litFabricTypeID.Text = kv.Key.ToString();

                int        value = kv.Key;
                FabricType type  = (FabricType)value;
                litFabricType.Text = type.ToString();

                FabricCodeBO objFC = new FabricCodeBO();
                objFC.ID = kv.Value.Key;
                objFC.GetObject();

                txtWhere.Text = kv.Value.Value;

                //litVFID.Text = "0";
                litID.Text             = objFC.ID.ToString();
                litCode.Text           = objFC.Code;
                litFabricNickName.Text = objFC.NickName;
                litFabricSupplier.Text = (objFC.Supplier.HasValue && objFC.Supplier.Value > 0) ? objFC.objSupplier.Name : string.Empty;
                //    ddlfabricCodeType.Items.FindByValue(kv.Key.Item2.ToString()).Selected = true;
                //}
            }
        }
        protected void dgSelectedFabrics_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DataGridItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is FabricCodeBO)
            {
                FabricCodeBO objFabric = (FabricCodeBO)item.DataItem;
                PriceBO      objPrice  = (new PriceBO()).GetAllObject().SingleOrDefault(o => o.Pattern == int.Parse(this.hdnPattern.Value) && o.FabricCode == objFabric.ID);

                Literal    lblCreator    = (Literal)item.FindControl("lblCreator");
                Literal    lblCreateDate = (Literal)item.FindControl("lblCreateDate");
                LinkButton btnAddNote    = (LinkButton)item.FindControl("btnAddNote");
                Literal    litModifier   = (Literal)item.FindControl("litModifier");
                Literal    litMofiedDate = (Literal)item.FindControl("litMofiedDate");
                HyperLink  linkDelete    = (HyperLink)item.FindControl("linkDelete");
                HyperLink  linkEdit      = (HyperLink)item.FindControl("linkEdit");

                if (objPrice != null)
                {
                    lblCreator.Text    = objPrice.objCreator.GivenName + " " + objPrice.objCreator.FamilyName;
                    lblCreateDate.Text = objPrice.CreatedDate.ToString("dd MMMM yyyy");
                    litModifier.Text   = objPrice.objModifier.GivenName + " " + objPrice.objModifier.FamilyName;
                    litMofiedDate.Text = objPrice.ModifiedDate.ToString("dd MMMM yyyy");
                    btnAddNote.Attributes.Add("pid", objPrice.ID.ToString());
                    linkDelete.Attributes.Add("qid", objPrice.ID.ToString());
                    linkEdit.Attributes.Add("pid", objPrice.ID.ToString());
                    linkEdit.Attributes.Add("fid", objFabric.ID.ToString());
                }
                else
                {
                    lblCreator.Text    = LoggedUser.GivenName + " " + LoggedUser.FamilyName;
                    lblCreateDate.Text = DateTime.Now.ToString("dd MMMM yyyy");
                    litModifier.Text   = LoggedUser.GivenName + " " + LoggedUser.FamilyName;
                    litMofiedDate.Text = DateTime.Now.ToString("dd MMMM yyyy");
                }
            }
        }
Ejemplo n.º 9
0
        private void ProcessForm(int fabricID, bool isDelete, bool isPure)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    FabricCodeBO objFabricCode = new FabricCodeBO(this.ObjContext);
                    if (fabricID > 0)
                    {
                        objFabricCode.ID = fabricID;
                        objFabricCode.GetObject();
                    }

                    if (isDelete)
                    {
                        objFabricCode.Delete();
                    }
                    else
                    {
                        //if (isPure)
                        //{
                        objFabricCode.Code           = this.txtCode.Text;
                        objFabricCode.Name           = this.txtName.Text;
                        objFabricCode.NickName       = (!String.IsNullOrEmpty(this.txtNickName.Text)) ? this.txtNickName.Text : string.Empty;
                        objFabricCode.IsActive       = (this.chbIsActive.Checked) ? true : false;
                        objFabricCode.IsLiningFabric = (this.chkIsLining.Checked) ? true : false;
                        objFabricCode.IsPure         = (this.chbIsPure.Checked) ? true : false;

                        objFabricCode.Supplier    = int.Parse(this.ddlSupplier.SelectedValue);
                        objFabricCode.Material    = (!String.IsNullOrEmpty(this.txtMaterial.Text)) ? this.txtMaterial.Text : string.Empty;
                        objFabricCode.GSM         = (!String.IsNullOrEmpty(this.txtGsm.Text)) ? this.txtGsm.Text : string.Empty;
                        objFabricCode.DenierCount = (!String.IsNullOrEmpty(this.txtDenierCount.Text)) ? this.txtDenierCount.Text : string.Empty;
                        objFabricCode.Filaments   = (!String.IsNullOrEmpty(this.txtFilaments.Text)) ? this.txtFilaments.Text : string.Empty;
                        objFabricCode.SerialOrder = (!String.IsNullOrEmpty(this.txtSerialOrder.Text)) ? this.txtSerialOrder.Text : string.Empty;
                        objFabricCode.FabricPrice = (!String.IsNullOrEmpty(this.txtFabricPrice.Text)) ? decimal.Parse(this.txtFabricPrice.Text) : decimal.Parse("0.0");
                        objFabricCode.Fabricwidth = (!String.IsNullOrEmpty(this.txtFabricWidth.Text)) ? this.txtFabricWidth.Text : string.Empty;
                        objFabricCode.Unit        = int.Parse(this.ddlUnit.SelectedValue);
                        objFabricCode.FabricColor = int.Parse(this.ddlFabricColor.SelectedValue);
                        objFabricCode.Country     = int.Parse(this.ddlCountry.SelectedValue);

                        if (int.Parse(this.ddlLandedCurrency.SelectedValue) > 0)
                        {
                            objFabricCode.LandedCurrency = int.Parse(this.ddlLandedCurrency.SelectedValue);
                        }
                        //}
                        //else
                        //{
                        //    objFabricCode.Code = this.txtFabricCode.Text;
                        //    objFabricCode.Name = this.txtCombinedName.Text;
                        //    objFabricCode.NickName = (!String.IsNullOrEmpty(this.txtCombinedNickName.Text)) ? this.txtCombinedNickName.Text : string.Empty;
                        //    objFabricCode.IsActive = (this.chkCombinedIsActive.Checked) ? true : false;

                        //    objFabricCode.IsLiningFabric = (this.chkIsLining.Checked) ? true : false;
                        //    objFabricCode.IsPure = false;
                        //    objFabricCode.Country = 14;
                        //}

                        if (fabricID == 0)
                        {
                            objFabricCode.Add();
                        }
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                // Log the error
                IndicoLogging.log.Error("Error occured while Saving Fabric", ex);
            }
        }
Ejemplo n.º 10
0
        private List <KeyValuePair <int, KeyValuePair <int, string> > > GetFilteredFabricData(int fabricID, int typeID, bool isDeleted)
        {
            List <KeyValuePair <int, KeyValuePair <int, string> > > lst = new List <KeyValuePair <int, KeyValuePair <int, string> > >();

            foreach (DataGridItem item in this.dgvAddEditFabrics.Items)
            {
                Literal litID           = (Literal)item.FindControl("litID");
                Literal litFabricTypeID = (Literal)item.FindControl("litFabricTypeID");
                Literal litFabricType   = (Literal)item.FindControl("litFabricType");
                TextBox txtWhere        = (TextBox)item.FindControl("txtWhere");

                lst.Add(new KeyValuePair <int, KeyValuePair <int, string> >(int.Parse(litFabricTypeID.Text), new KeyValuePair <int, string>(int.Parse(litID.Text), txtWhere.Text)));
            }

            if (fabricID > 0) // Add, Delete
            {
                if (isDeleted)
                {
                    KeyValuePair <int, KeyValuePair <int, string> > removeFabric = lst.Where(m => m.Key == typeID && m.Value.Key == fabricID).SingleOrDefault();
                    lst.Remove(removeFabric);
                }
                else
                {
                    lst.Add(new KeyValuePair <int, KeyValuePair <int, string> >(typeID, new KeyValuePair <int, string>(fabricID, "")));
                }
            }
            else // Page edit mode to load all data
            {
                if (this.QueryID > 0)
                {
                    FabricCodeBO objFabric = new FabricCodeBO();
                    objFabric.ID = QueryID;
                    objFabric.GetObject();

                    this.txtCombinedName.Text        = objFabric.Name;
                    this.txtCombinedNickName.Text    = objFabric.NickName;
                    this.chkCombinedIsActive.Checked = objFabric.IsActive;

                    try
                    {
                        string[] codes = objFabric.Code.Split('+');
                        //string[] wheres = string.IsNullOrEmpty(objVL.Where) ? new string[0] : objVL.Where.Split(',');

                        List <KeyValuePair <int, string> > lstWheres = new List <KeyValuePair <int, string> >();

                        //foreach (string whereText in wheres)
                        //{
                        //    lstWheres.Add(new KeyValuePair<int, string>(int.Parse(whereText.Split('-')[0]), whereText.Split('-')[1]));
                        //}

                        List <FabricCodeBO> lstFabricCodes = (List <FabricCodeBO>)Session["ListFabricCodes"];

                        int fabricPosition = 0;

                        foreach (string code in codes)
                        {
                            FabricCodeBO objFabCode = lstFabricCodes.Where(m => m.Code == code).Single();
                            string       whereText  = lstWheres.Where(m => m.Key == objFabCode.ID).SingleOrDefault().Value;

                            if (++fabricPosition == 1)
                            {
                                lst.Add(new KeyValuePair <int, KeyValuePair <int, string> >((int)FabricType.Main, new KeyValuePair <int, string>(objFabCode.ID, whereText)));
                            }
                            else if (objFabCode.IsLiningFabric)
                            {
                                lst.Add(new KeyValuePair <int, KeyValuePair <int, string> >((int)FabricType.Lining, new KeyValuePair <int, string>(objFabCode.ID, whereText)));
                            }
                            else
                            {
                                lst.Add(new KeyValuePair <int, KeyValuePair <int, string> >((int)FabricType.Secondary, new KeyValuePair <int, string>(objFabCode.ID, whereText)));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            Session["CombinedFabrics"] = lst;
            return(lst);
        }
Ejemplo n.º 11
0
        private void PopulateFabricName()
        {
            string mainFabName      = string.Empty;
            string secondaryFabName = string.Empty;
            string liningFabName    = string.Empty;

            string combinedName     = string.Empty;
            string combinedNickName = string.Empty;

            foreach (DataGridItem item in this.dgvAddEditFabrics.Items)
            {
                Literal litID           = (Literal)item.FindControl("litID");
                Literal litFabricTypeID = (Literal)item.FindControl("litFabricTypeID");

                FabricCodeBO objFab = new FabricCodeBO();
                objFab.ID = int.Parse(litID.Text);
                objFab.GetObject();

                if (int.Parse(litFabricTypeID.Text) == 0)
                {
                    mainFabName = objFab.Code;
                }
                else if (objFab.IsLiningFabric)
                {
                    liningFabName += objFab.Code + "+";
                }
                else
                {
                    secondaryFabName += objFab.Code + "+";
                }

                combinedName     += objFab.Name + " + ";
                combinedNickName += objFab.NickName + " + ";
            }

            liningFabName    = string.IsNullOrEmpty(liningFabName) ? "" : "+" + liningFabName.Remove(liningFabName.Length - 1, 1);
            secondaryFabName = string.IsNullOrEmpty(secondaryFabName) ? "" : "+" + secondaryFabName.Remove(secondaryFabName.Length - 1, 1);

            combinedName     = string.IsNullOrEmpty(combinedName) ? "" : combinedName.Remove(combinedName.Length - 3, 3);
            combinedNickName = string.IsNullOrEmpty(combinedNickName) ? "" : combinedNickName.Remove(combinedNickName.Length - 3, 3);

            string selectedFabric = mainFabName + secondaryFabName + liningFabName;

            this.txtFabricCode.Text       = selectedFabric;
            this.txtCombinedName.Text     = combinedName;
            this.txtCombinedNickName.Text = combinedNickName;

            List <FabricCodeBO> lstFabricCodes = (List <FabricCodeBO>)Session["ListFabricCodes"];

            if (!string.IsNullOrEmpty(selectedFabric) && lstFabricCodes != null)
            {
                try
                {
                    lstFabricCodes = lstFabricCodes.Where(m => m.Code == selectedFabric).ToList();

                    if (lstFabricCodes.Any())
                    {
                        if (this.QueryID == 0 || (this.QueryID > 0 && !lstFabricCodes.Select(m => m.ID).Contains(this.QueryID)))
                        {
                            CustomValidator cv = new CustomValidator();
                            cv.IsValid         = false;
                            cv.ValidationGroup = "valCombined";
                            cv.ErrorMessage    = "Fabric Code exists in the system.";
                            Page.Validators.Add(cv);
                        }
                    }
                }
                catch (Exception ex)
                {
                    //lblVLFabricErrorText.Text = "The fabric combination selected, does not exist in Indiman Price List.  Please contact Indiman administrator to include in fabric combination list.";
                }
            }
        }