private void PopulateDataGrid() { // Hide Controls // this.dvEmptyContent.Visible = false; this.dvDataContent.Visible = false; this.dvNoSearchResult.Visible = false; // Search text string searchText = this.txtSearch.Text.ToLower().Trim(); // Populate Size SizeBO objSize = new SizeBO(); List <SizeBO> lstSize = new List <SizeBO>(); if ((searchText != string.Empty) && (searchText != "search")) { lstSize = (from o in objSize.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList <SizeBO>() where o.SizeName.ToLower().Contains(searchText) || o.SeqNo.ToString().Contains(searchText) || o.objSizeSet.Name.ToLower().Contains(searchText) select o).ToList(); } else { lstSize = objSize.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList <SizeBO>(); } if (lstSize.Count > 0) { this.dgAddEditSizes.AllowPaging = (lstSize.Count > this.dgAddEditSizes.PageSize); this.dgAddEditSizes.DataSource = lstSize; this.dgAddEditSizes.DataBind(); this.dvDataContent.Visible = true; } else if ((searchText != string.Empty && searchText != "search")) { this.lblSerchKey.Text = searchText + ((searchText != string.Empty) ? " - " : string.Empty); this.dvDataContent.Visible = true; this.dvNoSearchResult.Visible = true; } else { //this.dvEmptyContent.Visible = true; this.btnAddSizes.Visible = false; } // this.lblSerchKey.Text = string.Empty; this.dgAddEditSizes.Visible = (lstSize.Count > 0); }
private void DeleteSize(int queryId) { try { if (queryId > 0) { using (TransactionScope ts = new TransactionScope()) { SizeBO objSize = new SizeBO(this.ObjContext); objSize.ID = queryId; objSize.GetObject(); List <int> lstSizeCharts = objSize.SizeChartsWhereThisIsSize.Select(o => o.ID).ToList(); foreach (int sizeChart in lstSizeCharts) { SizeChartBO objSizeChart = new SizeChartBO(this.ObjContext); objSizeChart.ID = sizeChart; objSizeChart.GetObject(); objSizeChart.Delete(); } objSize.Delete(); this.ObjContext.SaveChanges(); ts.Complete(); } } else { if (Session["ListSizes"] != null) { List <KeyValuePair <int, SizeBO> > lstEmptyList = (List <KeyValuePair <int, SizeBO> >)Session["ListSizes"]; KeyValuePair <int, SizeBO> objSize = lstEmptyList.Where(m => m.Key == queryId).FirstOrDefault(); lstEmptyList.Remove(objSize); Session["ListSizes"] = lstEmptyList; } } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while Deleting the Size", ex); } }
protected void dgAddEditSizes_ItemDataBound(object sender, DataGridItemEventArgs e) { DataGridItem item = e.Item; if (item.ItemIndex > -1 && item.DataItem is SizeBO) { SizeBO objSize = (SizeBO)item.DataItem; Label lblSizeSet = (Label)item.FindControl("lblSizeSet"); lblSizeSet.Text = objSize.objSizeSet.Name; Label lblSizeName = (Label)item.FindControl("lblSizeName"); lblSizeName.Text = objSize.SizeName; Label lblSeqNo = (Label)item.FindControl("lblSeqNo"); lblSeqNo.Text = objSize.SeqNo.ToString(); HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete"); linkDelete.Attributes.Add("qid", objSize.ID.ToString()); } }
/// <summary> /// Process the page data. /// </summary> private void ProcessForm(int queryId, bool isDelete) { try { using (TransactionScope ts = new TransactionScope()) { SizeBO objSize = new SizeBO(this.ObjContext); if (queryId > 0) { objSize.ID = queryId; objSize.GetObject(); } if (isDelete) { objSize.Delete(); } else { objSize.SizeName = this.txtSizeName.Text; objSize.SeqNo = int.Parse(this.txtSeqNo.Text); objSize.SizeSet = int.Parse(this.ddlSizeSet.SelectedItem.Value); if (queryId == 0) { objSize.Add(); } } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { // Log the error //IndicoLogging.log("Error occured while Adding the Item", ex); } }
private void ProcessSizeSet(bool isNewSize) { try { using (TransactionScope ts = new TransactionScope()) { SizeBO objSize = new SizeBO(this.ObjContext); if (!isNewSize) { objSize.ID = int.Parse(this.hdnSelectedSizeID.Value); objSize.GetObject(); } objSize.IsDefault = (int.Parse(this.hdnIsDefault.Value.ToString()) > 0) ? true : false; objSize.SizeName = this.hdnSizeName.Value.ToString(); objSize.SeqNo = int.Parse(this.hdnSeqNo.Value.ToString()); if (isNewSize) { int itemId = int.Parse(this.ddlSizeSet.SelectedValue.ToString()); SizeSetBO objSizeSet = new SizeSetBO(this.ObjContext); objSizeSet.ID = itemId; objSizeSet.GetObject(); objSizeSet.SizesWhereThisIsSizeSet.Add(objSize); } this.ObjContext.SaveChanges(); ts.Complete(); } } catch (Exception ex) { IndicoLogging.log.Error("Error occured while processing Sizes", ex); } }
private void GetDiffrenceGarmentSpec(int original, int compare) { PatternBO objOriPattern = new PatternBO(); objOriPattern.ID = original; objOriPattern.GetObject(); PatternBO objComPattern = new PatternBO(); objComPattern.ID = compare; objComPattern.GetObject(); List <SizeChartBO> lstDiffrence = new List <SizeChartBO>(); List <SizeChartBO> lstOriSizeCharts = objOriPattern.SizeChartsWhereThisIsPattern; List <SizeChartBO> lstCComSizeCharts = objComPattern.SizeChartsWhereThisIsPattern; foreach (SizeChartBO osc in lstOriSizeCharts) { foreach (SizeChartBO csc in lstCComSizeCharts) { if (osc.Size == csc.Size && osc.MeasurementLocation == csc.MeasurementLocation) { decimal difference = (osc.Val - csc.Val); MeasurementLocationBO objM = new MeasurementLocationBO(); objM.ID = csc.MeasurementLocation; objM.GetObject(); SizeBO objSize = new SizeBO(); objSize.ID = csc.Size; objSize.GetObject(); SizeChartBO objSizeChart = new SizeChartBO(); objSizeChart.ID = 0; objSizeChart.Pattern = csc.Pattern;// Not necessary objSizeChart.MeasurementLocation = osc.MeasurementLocation; objSizeChart.objPattern = objComPattern; objSizeChart.Size = csc.Size; objSizeChart.objSize = objSize; objSizeChart.MeasurementLocation = csc.MeasurementLocation; objSizeChart.objMeasurementLocation = objM; objSizeChart.Val = difference; lstDiffrence.Add(objSizeChart); } } } List <IGrouping <int, SizeChartBO> > lstSizeChartGroup = lstDiffrence.OrderBy(o => o.objMeasurementLocation.Key).GroupBy(o => o.MeasurementLocation).ToList(); if (lstSizeChartGroup.Count > 0) { this.rptDiffSpecSizeQtyHeader.DataSource = (List <SizeChartBO>)lstSizeChartGroup[0].ToList(); this.rptDiffSpecSizeQtyHeader.DataBind(); this.rptDiffSpecML.DataSource = lstSizeChartGroup; this.rptDiffSpecML.DataBind(); this.dvDiffrence.Visible = true; } }
/// <summary> /// Process the page data. /// </summary> private void ProcessForm(int queryId, bool isDelete) { try { using (TransactionScope ts = new TransactionScope()) { if (!isDelete) { SizeSetBO objSizeSet = new SizeSetBO(this.ObjContext); if (queryId > 0) { objSizeSet.ID = queryId; objSizeSet.GetObject(); } List <int> lstSizeIds = objSizeSet.SizesWhereThisIsSizeSet.Select(o => o.ID).ToList(); this.dgAddEditSizes.AllowPaging = false; foreach (DataGridItem item in this.dgAddEditSizes.Items) { //HiddenField hdnSizeID = (HiddenField)item.FindControl("hdnSizeID"); Literal lblID = (Literal)item.FindControl("lblID"); TextBox txtSizeName = (TextBox)item.FindControl("txtSizeName"); TextBox txtSeqNo = (TextBox)item.FindControl("txtSeqNo"); CheckBox chkIsDefault = (CheckBox)item.FindControl("chkIsDefault"); int sizeId = int.Parse(lblID.Text); SizeBO objSize = new SizeBO(this.ObjContext); if (sizeId > 0 && lstSizeIds.Contains(sizeId)) // edit { objSize.ID = sizeId; objSize.GetObject(); objSize.SizeSet = int.Parse(ddlSizeSet.SelectedItem.Value); objSize.IsDefault = chkIsDefault.Checked; objSize.SizeName = txtSizeName.Text; objSize.SeqNo = int.Parse(txtSeqNo.Text); } else // new { objSize.SizeSet = int.Parse(ddlSizeSet.SelectedItem.Value); objSize.IsDefault = chkIsDefault.Checked; objSize.SizeName = txtSizeName.Text; objSize.SeqNo = int.Parse(txtSeqNo.Text); objSizeSet.SizesWhereThisIsSizeSet.Add(objSize); } //if (lstSizeIds.Count == 0 || !lstSizeIds.Contains(sizeId)) //New Size //{ // //Label lblSizeName = (Label)item.FindControl("lblSizeName"); // //Label lblSeqNo = (Label)item.FindControl("lblSeqNo"); // //Label lblSizeSet = (Label)item.FindControl("lblSizeSet"); // //SizeBO objSize = new SizeBO(this.ObjContext); // //objSize.SizeSet = int.Parse(ddlSizeSet.SelectedItem.Value); // //objSize.SizeName = lblSizeName.Text; // //objSize.SeqNo = int.Parse(lblSeqNo.Text); // //objSizeSet.SizesWhereThisIsSizeSet.Add(objSize); // //Label lblSizeSet = (Label)item.FindControl("lblSizeSet"); //} //lstSizeIds.Remove(sizeId); } //if (lstSizeIds.Count > 0) //{ // foreach (int sizeId in lstSizeIds) // { // SizeBO objSize = new SizeBO(this.ObjContext); // objSize.ID = sizeId; // objSize.GetObject(); // objSizeSet.SizesWhereThisIsSizeSet.Remove(objSize); // objSize.Delete(); // } //} this.ObjContext.SaveChanges(); } else //Delete Size { SizeBO objSize = new SizeBO(this.ObjContext); if (queryId > 0) { objSize.ID = queryId; objSize.GetObject(); objSize.Delete(); this.ObjContext.SaveChanges(); } } ts.Complete(); } } catch (Exception ex) { // Log the error //IndicoLogging.log("Error occured while Adding the Item", ex); } }
//private void PopulateSizeSet(bool addNewRecord) //{ // this.PopulateSizeSet(addNewRecord, 0); //} private void PopulateSizeSet(bool addNewRecord) { if (this.IsNotRefresh) { //this.dgAddEditSizes.CurrentPageIndex = currentPageIndex; //this.dgAddEditSizes.EditItemIndex = editItemIndex; SizeBO obj = new SizeBO(); obj.SizeSet = int.Parse(this.ddlSizeSet.SelectedValue.ToString()); //List<SizeBO> lstEmptyList = new List<SizeBO>(); List <KeyValuePair <int, SizeBO> > lstEmptyList = new List <KeyValuePair <int, SizeBO> >(); //if (editItemIndex > -1) //{ List <SizeBO> lstExsistingSizes = obj.SearchObjects().OrderBy(o => o.SeqNo).ToList(); foreach (SizeBO objSize in lstExsistingSizes) { lstEmptyList.Add(new KeyValuePair <int, SizeBO>(objSize.ID, objSize)); } //} //else if (Session["ListSizes"] != null) //{ // lstEmptyList = (List<KeyValuePair<int, SizeBO>>)Session["ListSizes"]; //} //else //{ // List<SizeBO> lstExsistingSizes = obj.SearchObjects().OrderBy(o => o.SeqNo).ToList(); // foreach (SizeBO objSize in lstExsistingSizes) // { // lstEmptyList.Add(new KeyValuePair<int, SizeBO>(objSize.ID, objSize)); // } //} if (addNewRecord || lstEmptyList.Count == 0) { SizeBO objSize = new SizeBO(); objSize.ID = 0; objSize.SizeSet = int.Parse(this.ddlSizeSet.SelectedValue.ToString()); objSize.SizeName = string.Empty; //objSize.SeqNo = 0; int nextID = 0; // (lstEmptyList.Select(m => m.Key).Min() > 0) ? 0 : (lstEmptyList.Select(m => m.Key).Min() - 1); lstEmptyList.Insert(0, new KeyValuePair <int, SizeBO>(nextID, objSize)); if (dgAddEditSizes.CurrentPageIndex > Math.Floor((double)(lstEmptyList.Count / dgAddEditSizes.PageSize))) { dgAddEditSizes.CurrentPageIndex = Convert.ToInt32(Math.Floor((double)(lstEmptyList.Count / dgAddEditSizes.PageSize))); } this.dgAddEditSizes.EditItemIndex = 0;//lstEmptyList.Count - 1; } this.dgAddEditSizes.DataSource = lstEmptyList; this.dgAddEditSizes.DataBind(); ViewState["IsPopulateModel"] = true; Session["ListSizes"] = lstEmptyList; } else { ViewState["IsPopulateModel"] = false; ViewState["IsPageValid"] = true; } }