Ejemplo n.º 1
0
		private Int64 SaveRecord()
		{
			ProductSubGroupDetails clsDetails = new ProductSubGroupDetails();

			clsDetails.ProductGroupID = Convert.ToInt32(cboGroup.SelectedItem.Value);
			clsDetails.ProductSubGroupCode = txtProductSubGroupCode.Text;
			clsDetails.ProductSubGroupName = txtProductSubGroupName.Text;
			clsDetails.BaseUnitID = Convert.ToInt32(cboProductSubGroupUnit.SelectedItem.Value);
			clsDetails.Price = Convert.ToDecimal(txtProductPrice.Text);
			clsDetails.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
			clsDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(chkIncludeInSubtotalDiscount.Checked);
			clsDetails.VAT = Convert.ToDecimal(txtVAT.Text);
			clsDetails.EVAT = Convert.ToDecimal(txtEVAT.Text);
			clsDetails.LocalTax = Convert.ToDecimal(txtLocalTax.Text);
            clsDetails.SequenceNo = Int32.Parse(txtSequenceNo.Text);
            clsDetails.ImagePath = lblImagePath.Text;

            string strfile = "";
            string strfolder = "/RetailPlus/temp/uploaded/subgroupimages/";
            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFile pfile = Request.Files[i];
                if (pfile.ContentLength > 0)
                {
                    strfile = Server.MapPath(strfolder + System.IO.Path.GetFileName(pfile.FileName));

                    if (!System.IO.Directory.Exists(Server.MapPath(strfolder)))
                        System.IO.Directory.CreateDirectory(Server.MapPath(strfolder));

                    if (System.IO.File.Exists(strfile))
                        System.IO.File.Delete(strfile);

                    pfile.SaveAs(strfile);
                    clsDetails.ImagePath = pfile.FileName;
                }
            }

			ProductSubGroup clsProductSubGroup = new ProductSubGroup();
			Int64 id = clsProductSubGroup.Insert(clsDetails);
			clsDetails.ProductSubGroupID = id;

			if (chkVariations.Checked == true)
			{
				clsProductSubGroup.InheritGroupVariations(clsDetails.ProductGroupID, clsDetails.ProductSubGroupID);
			}

			if (chkVariationsMatrix.Checked == true)
			{
				if (chkVariations.Checked == false)
				{
					clsProductSubGroup.InheritGroupVariations(clsDetails.ProductGroupID, clsDetails.ProductSubGroupID);
				}
				clsProductSubGroup.InheritGroupVariationsMatrix(clsDetails.ProductGroupID, clsDetails.ProductSubGroupID);
			}
			if (chkUnitMatrix.Checked == true)
			{
				clsProductSubGroup.InheritGroupUnitMatrix(clsDetails.ProductGroupID, clsDetails.ProductSubGroupID);
			}

			clsProductSubGroup.CommitAndDispose();

			return id;
		}