Example #1
0
        protected void lstItem_ItemDataBound(object sender, DataListItemEventArgs e)
		{
			if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
			{
				DataRowView dr = (DataRowView) e.Item.DataItem;				

				HtmlInputCheckBox chkList = (HtmlInputCheckBox) e.Item.FindControl("chkList");
				chkList.Value = dr["VariationID"].ToString();

                HyperLink lnkVariationType = (HyperLink)e.Item.FindControl("lnkVariationType");
                lnkVariationType.Text = dr["VariationType"].ToString(); //VariationID
                lnkVariationType.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Variation/Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(dr["VariationID"].ToString(), Session.SessionID);
				
				ProductGroupVariationsMatrix clsProductGroupVariationsMatrix = new ProductGroupVariationsMatrix();
				TextBox txtDescription = (TextBox) e.Item.FindControl("txtDescription");
				txtDescription.Text = clsProductGroupVariationsMatrix.Details(Convert.ToInt32(lblMatrixID.Text), Convert.ToInt32(chkList.Value)).Description;
				clsProductGroupVariationsMatrix.CommitAndDispose();

			}
		}
Example #2
0
		private bool SaveRecord()
		{
			ProductGroupVariationsMatrixDetails clsDetails;
			ProductGroupVariationsMatrix clsProductGroupVariationsMatrix = new ProductGroupVariationsMatrix();

			string stringVariationDesc = null;

			foreach (DataListItem item in lstItem.Items)
			{
				HtmlInputCheckBox chkList = (HtmlInputCheckBox) item.FindControl("chkList");
				TextBox txtDescription = (TextBox) item.FindControl("txtDescription");
				
				clsDetails = new ProductGroupVariationsMatrixDetails();
				clsDetails.MatrixID = Convert.ToInt32(lblMatrixID.Text);
				clsDetails.GroupID = Convert.ToInt32(lblGroupID.Text);
				clsDetails.VariationID = Convert.ToInt32(chkList.Value);
				clsDetails.Description = txtDescription.Text;
				
				if (clsProductGroupVariationsMatrix.IsVariationExists(clsDetails.MatrixID, clsDetails.VariationID) == false)
				{
					clsProductGroupVariationsMatrix.InsertVariation(clsDetails);
				}
				else
				{
					clsProductGroupVariationsMatrix.UpdateVariation(clsDetails);
				}

                //Label lblVariationType = (Label) item.FindControl("lblVariationType");
                //stringVariationDesc += lblVariationType.Text + ":" + txtDescription.Text + "; ";
                stringVariationDesc += txtDescription.Text + "; ";
			}
			
			//update the base variation matrix
			ProductGroupBaseVariationsMatrixDetails clsBaseDetails = new ProductGroupBaseVariationsMatrixDetails();
			clsBaseDetails.MatrixID = Convert.ToInt32(lblMatrixID.Text);
			clsBaseDetails.GroupID = Convert.ToInt32(lblGroupID.Text);
			clsBaseDetails.Description = stringVariationDesc;
			clsBaseDetails.UnitID = Convert.ToInt32(cboUnit.SelectedItem.Value);
			clsBaseDetails.Price = Convert.ToDecimal(txtProductPrice.Text);
			clsBaseDetails.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
			clsBaseDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(chkIncludeInSubtotalDiscount.Checked);
			clsBaseDetails.VAT = Convert.ToDecimal(txtVAT.Text);
			clsBaseDetails.EVAT = Convert.ToDecimal(txtEVAT.Text);
			clsBaseDetails.LocalTax = Convert.ToDecimal(txtLocalTax.Text);
			clsProductGroupVariationsMatrix.UpdateBaseVariation(clsBaseDetails);

			clsProductGroupVariationsMatrix.CommitAndDispose();

			return true;
		}
Example #3
0
		private void LoadRecord()
		{
			ProductGroupVariationsMatrix clsProductGroupVariationsMatrix = new ProductGroupVariationsMatrix();
			ProductGroupBaseVariationsMatrixDetails clsBaseDetails = clsProductGroupVariationsMatrix.BaseDetails(Convert.ToInt32(lblMatrixID.Text), Convert.ToInt32(lblGroupID.Text));
			clsProductGroupVariationsMatrix.CommitAndDispose();

			cboUnit.SelectedIndex = cboUnit.Items.IndexOf(cboUnit.Items.FindByValue(clsBaseDetails.UnitID.ToString()));
			txtProductPrice.Text = clsBaseDetails.Price.ToString("#,##0.#0");
			txtPurchasePrice.Text = clsBaseDetails.PurchasePrice.ToString("#,##0.#0");
            decimal decMargin = clsBaseDetails.Price - clsBaseDetails.PurchasePrice;
            try { decMargin = decMargin / clsBaseDetails.PurchasePrice; }
            catch { decMargin = 1; }
            decMargin = decMargin * 100;
            txtMargin.Text = decMargin.ToString("#,##0.##0");
            chkIncludeInSubtotalDiscount.Checked = clsBaseDetails.IncludeInSubtotalDiscount;
			txtVAT.Text = clsBaseDetails.VAT.ToString("#,##0.#0");
			txtEVAT.Text = clsBaseDetails.EVAT.ToString("#,##0.#0");
			txtLocalTax.Text = clsBaseDetails.LocalTax.ToString("#,##0.#0");
			
		}
Example #4
0
		private bool Delete()
		{
			bool boRetValue = false;
			string stIDs = "";

			foreach(DataListItem item in lstItem.Items)
			{
				HtmlInputCheckBox chkList = (HtmlInputCheckBox) item.FindControl("chkList");
				if (chkList!=null)
				{
					if (chkList.Checked == true)
					{
						stIDs += chkList.Value + ",";		
						boRetValue = true;
					}
				}
			}
			if (boRetValue)
			{
				ProductGroupVariationsMatrix clsProductGroupVariationsMatrix = new ProductGroupVariationsMatrix();
				clsProductGroupVariationsMatrix.Delete(stIDs.Substring(0,stIDs.Length-1));
				clsProductGroupVariationsMatrix.CommitAndDispose();
			}

			return boRetValue;
		}
Example #5
0
		private void LoadList()
		{	
			ProductGroupVariationsMatrix clsProductGroupVariationsMatrix = new ProductGroupVariationsMatrix();
			DataClass clsDataClass = new DataClass();

			string SortField = "MatrixID";
			if (Request.QueryString["sortfield"]!=null)
			{	SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);	}
			
			SortOption sortoption = SortOption.Ascending;
			if (Request.QueryString["sortoption"]!=null)
			{	sortoption = (SortOption) Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);	}

			if (Request.QueryString["Search"]==null)
			{
				PageData.DataSource = clsDataClass.DataReaderToDataTable(clsProductGroupVariationsMatrix.BaseList(Convert.ToInt64(lblGroupID.Text), SortField, sortoption)).DefaultView;
			}
			else
			{						
				string SearchKey = Common.Decrypt((string)Request.QueryString["search"],Session.SessionID);
				PageData.DataSource = clsDataClass.DataReaderToDataTable(clsProductGroupVariationsMatrix.Search(Convert.ToInt64(lblGroupID.Text), SearchKey, SortField, sortoption)).DefaultView;
			}

			clsProductGroupVariationsMatrix.CommitAndDispose();

			int iPageSize = Convert.ToInt16(Session["PageSize"]) ;
			
			PageData.AllowPaging = true;
			PageData.PageSize = iPageSize;
			try
			{
				PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;				
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}
			catch
			{
				PageData.CurrentPageIndex = 1;
				lstItem.DataSource = PageData;
				lstItem.DataBind();
			}			
			
			cboCurrentPage.Items.Clear();
			for (int i=0; i < PageData.PageCount;i++)
			{
				int iValue = i + 1;
				cboCurrentPage.Items.Add(new ListItem(iValue.ToString(),iValue.ToString()));
				if (PageData.CurrentPageIndex == i)
				{	cboCurrentPage.Items[i].Selected = true;}
				else
				{	cboCurrentPage.Items[i].Selected = false;}
			}
			lblDataCount.Text = " of " + " " + PageData.PageCount;
		}
Example #6
0
        protected void lstItem_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            HtmlInputCheckBox chkList = null;
            string stParam = string.Empty;

            chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList");

            switch (e.CommandName)
            {
                case "imgItemDelete":
                    ProductGroupVariationsMatrix clsProductGroupVariationsMatrix = new ProductGroupVariationsMatrix();
                    clsProductGroupVariationsMatrix.Delete(chkList.Value);
                    clsProductGroupVariationsMatrix.CommitAndDispose();

                    LoadList();
                    break;
                case "imgItemEdit":
                    stParam = "?task=" + Common.Encrypt("edit", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID) + "&groupid=" + Common.Encrypt(lblGroupID.Text, Session.SessionID);
                    Response.Redirect("Default.aspx" + stParam);
                    break;
            }
        }