protected void grpSubmitBtn_Click(object sender, EventArgs e) { if (grpImageFU.FileName != string.Empty && grpImageFU.FileContent.Length <= 1024000) { //bool flagItem; float billedrate = 0, netrate = 0; DataTable grpItemsDt = new DataTable(); DataColumn dc = new DataColumn("GrpItem", typeof(int)); grpItemsDt.Columns.Add(dc); foreach (GridViewRow dRow in SelectedItemGrid.Rows) { string nrate = dRow.Cells[4].Text.ToString(); string brate = dRow.Cells[3].Text.ToString(); billedrate += float.Parse(brate); netrate += float.Parse(nrate); int itemId = Convert.ToInt32(dRow.Cells[0].Text.ToString()); DataRow dr = grpItemsDt.NewRow(); dr[0] = itemId; grpItemsDt.Rows.Add(dr); } string grpItemString = ""; bool first = true; if (grpItemsDt.Rows.Count > 0) { foreach (DataRow iRow in grpItemsDt.Rows) { if (first) { grpItemString += int.Parse(iRow["GrpItem"].ToString()); first = false; } else { grpItemString += "," + int.Parse(iRow["GrpItem"].ToString()); } } float discount = float.Parse(grpDiscountTxt.Text); billedrate -= (billedrate * (discount / 100)); netrate = (netrate - (netrate * (discount / 100))); BusinessEntitiesBS.GroupEntities.grpObj grpValus = new BusinessEntitiesBS.GroupEntities.grpObj(); grpValus.grpName = grpNameTxt.Text.ToString(); grpValus.grpDesc = grpDescTxt.Text.ToString(); grpValus.grpBR = billedrate; grpValus.grpNR = netrate; //grpValus.grpBR = float.Parse(grpBrTxt.Text.ToString()); //grpValus.grpNR = float.Parse(grpNrTxt.Text.ToString()); grpValus.grpStatus = grpCb.Checked; grpValus.fixedGrp = grpStatusCb.Checked; grpValus.Quantity = Int32.Parse(grpQtyTxt.Text.ToString()); //item string grpValus.itemIdStr = grpItemString; IAdmin insertGroup = new AdminItems(); int grpId = insertGroup.insertGroup(grpValus); if (grpId != -1) { //create folder for item images and save images. show result string NewDir = Server.MapPath("~/GroupImages/" + "/" + grpId); try { // Check if directory exists if (!Directory.Exists(NewDir)) { // Create the directory. Directory.CreateDirectory(NewDir); } } catch (IOException _ex) { grpMsgLbl.Text = HardCodedValues.BuddaResource.FloderError + _ex.Message; } string filename = grpId + "Photo.jpg"; grpImageFU.SaveAs(Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + filename); string filePath = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + filename; string newfileMed = grpId + "Photomedium.jpg"; string newfileSmall = grpId + "small.jpg"; string resizedImageMed = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + newfileMed; string resizedImageSmall = Server.MapPath("~/GroupImages/" + "/" + grpId + "/") + newfileSmall; System.Drawing.Image img = System.Drawing.Image.FromFile(filePath); System.Drawing.Bitmap bmpD = img as Bitmap; Bitmap bmpDriverMed = new Bitmap(bmpD, 500, 500); bmpDriverMed.Save(resizedImageMed, System.Drawing.Imaging.ImageFormat.Jpeg); Bitmap bmpDriverSmall = new Bitmap(bmpD, 150, 150); bmpDriverSmall.Save(resizedImageSmall, System.Drawing.Imaging.ImageFormat.Jpeg); grpMsgLbl.Text = HardCodedValues.BuddaResource.GroupAdd; } else { grpMsgLbl.Text = HardCodedValues.BuddaResource.GroupNotAdded; } } else { grpMsgLbl.Text = HardCodedValues.BuddaResource.ItemSelect; } } else { grpMsgLbl.Text = HardCodedValues.BuddaResource.ImageSizeError; } ClearCache(); }
protected void grpSubmitBtn_Click(object sender, EventArgs e) { bool flagItem; DataTable grpItemsDt = new DataTable(); DataColumn dc = new DataColumn("GrpItem", typeof(int)); grpItemsDt.Columns.Add(dc); foreach (GridViewRow dRow in itemGrid.Rows) { flagItem = (dRow.FindControl("itemChkBox") as CheckBox).Checked; if (flagItem) { int itemId = Convert.ToInt32(itemGrid.DataKeys[dRow.RowIndex].Value); DataRow dr = grpItemsDt.NewRow(); dr[0] = itemId; grpItemsDt.Rows.Add(dr); } } string grpItemString = ""; bool first = true; if (grpItemsDt.Rows.Count > 0) { foreach (DataRow iRow in grpItemsDt.Rows) { if (first) { grpItemString += int.Parse(iRow["GrpItem"].ToString()); first = false; } else { grpItemString += "," + int.Parse(iRow["GrpItem"].ToString()); } } BusinessEntitiesBS.GroupEntities.grpObj grpValus = new BusinessEntitiesBS.GroupEntities.grpObj(); grpValus.grpName = grpNameTxt.Text.ToString(); grpValus.grpDesc = grpDescTxt.Text.ToString(); grpValus.grpBR = float.Parse(grpBrTxt.Text.ToString()); grpValus.grpNR = float.Parse(grpNrTxt.Text.ToString()); grpValus.grpStatus = grpCb.Checked; grpValus.fixedGrp = grpStatusCb.Checked; grpValus.Quantity = Int32.Parse(grpQtyTxt.Text.ToString()); //item string grpValus.itemIdStr = grpItemString; IAdmin insertGroup = new AdminItems(); int grpId = insertGroup.insertGroup(grpValus); if (grpId != -1) { grpMsgLbl.Text = "Group Inserted"; } else { grpMsgLbl.Text = "Error Occured! Group not inserted"; } } else { grpMsgLbl.Text = "Select items for the group"; } }