protected void BtnAddGroup_Click(object sender, EventArgs e) { string url = ""; Class_ImageResize ClsImage = new Class_ImageResize(); LabelErrorMessage.Text = ""; if (UploadCategory.HasFile) // CHECK IF ANY FILE HAS BEEN SELECTED. { HttpFileCollection hfc = Request.Files; if (hfc.Count <= 10) // 10 FILES RESTRICTION. { for (int i = 0; i <= hfc.Count - 1; i++) { HttpPostedFile hpf = hfc[i]; url = ClsImage.imageresize(hpf); } LabelErrorMessage.Text += "<br> Total <b>" + hfc.Count + "</b> file(s) "; } else { LabelErrorMessage.Text = "Max. 10 files allowed."; } } else { url = "UploadedImages/no-image-available.png"; } if (LblNodeValue.Text != "") { GetLevelParentChartID(); } else { Level = 1; ParentGroupId = 0; } Class1 queryResult = new Class1(); try { ItemGroupId = 0; accountantCls.Cmd.Connection.ConnectionString = accountantCls.GetConnStr(); accountantCls.Cmd.CommandType = CommandType.StoredProcedure; accountantCls.Cmd.CommandText = "USP_ItemGroup_Save"; accountantCls.Cmd.Parameters.Add("@ItemGroupId", SqlDbType.Int).Value = 0; accountantCls.Cmd.Parameters.Add("@CompanyId", SqlDbType.Int).Value = int.Parse(Session["CompanyId"].ToString()); accountantCls.Cmd.Parameters.Add("@BranchId", SqlDbType.Int).Value = Session["BranchId"]; accountantCls.Cmd.Parameters.Add("@Level", SqlDbType.Int).Value = Level; accountantCls.Cmd.Parameters.Add("@ItemGroupName", SqlDbType.NVarChar).Value = _ItemGroupNameText.Text; accountantCls.Cmd.Parameters.Add("@ParentGroupId", SqlDbType.NVarChar).Value = ParentGroupId; accountantCls.Cmd.Parameters.Add("@ItemGroupCode", SqlDbType.NVarChar).Value = _ItemGroupCodeText.Text; accountantCls.Cmd.Parameters.Add("@CategoryImage", SqlDbType.NVarChar).Value = url; if (ItemGroupId == 0) { accountantCls.Cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Session["UserCode"].ToString(); } else { accountantCls.Cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = ModifiedBy; } queryResult.ErrorNo = 0; accountantCls.beginTrans(); queryResult.RecordId = Convert.ToInt32(accountantCls.Cmd.ExecuteScalar()); if (queryResult.RecordId == 0) { queryResult.ErrorNo = -1; queryResult.ErrorDesc = Resources.ResourceMain.ChartAlreadyExists; queryResult.ErrorFunction = " Finance.DAL.ChartOfAccount.SaveGroup"; } else if (queryResult.RecordId == -1) { queryResult.ErrorNo = -1; queryResult.ErrorDesc = Resources.ResourceMain.EndOfLevel; queryResult.ErrorFunction = " Finance.DAL.ChartOfAccount.SaveGroup"; } accountantCls.Cmd.CommandType = CommandType.Text; accountantCls.Cmd.CommandText = "select ItemGroupCode From tItemGroups where ItemGroupId = " + queryResult.RecordId; queryResult.OtherData = accountantCls.Cmd.ExecuteScalar(); accountantCls.commitTrans(); LabelErrorMessage.Text = "Saved Successfully"; TreeView1.ExpandAll(); } catch (Exception ex) { accountantCls.rollBackTrans(); queryResult.ErrorDesc = ex.Message; queryResult.ErrorNo = -1; queryResult.ErrorFunction = " Finance.DAL.ChartOfAccount.SaveGroup"; } PopulateTreeView(); LblNodeValue.Text = ""; }
protected void btnCheckOut_Click(object sender, EventArgs e) { int qty = 0; decimal amt = 0; decimal price = 0; //int price = 0, amt = 0, qty = 0; Int32 OrderCode = 0; string invNo = ""; foreach (GridViewRow row in GridView1.Rows) { Label Code = (Label)row.FindControl("lblProductCode"); Session["ProCode"] = Code.Text; Label t1 = (Label)row.FindControl("lblPrice"); price = decimal.Parse(t1.Text); TextBox t2 = (TextBox)row.FindControl("txtQty0"); qty = int.Parse(t2.Text); Session["Qty"] = qty; amt = (price * qty) + amt; System.Data.SqlClient.SqlConnection MyCon = new SqlConnection(conString); MyCon.Open(); SqlCommand MyCmd = new SqlCommand(); MyCmd.Connection = MyCon; if (Session["OrderCode"] == null) { //QuotationId invNo = new Class_ImageResize().GetInvoiceNo(Session["CompanyId"].ToString(), "QuotationId", "tQuotations"); MyCmd.CommandText = "insert into tQuotations (CustomerId,CreatedBy,InvoiceNo,InvoiceType,InvoiceTotal) values('" + Session["UserCode"].ToString() + "','" + Session["UserCode"].ToString() + "','" + invNo + "','0' , '" + txtTotal.Text + "')"; MyCmd.ExecuteNonQuery(); string sSQL2 = "SELECT SCOPE_IDENTITY()"; MyCmd.CommandText = sSQL2; MyCmd.CommandType = CommandType.Text; MyCmd.Connection = MyCon; OrderCode = Convert.ToInt32(MyCmd.ExecuteScalar()); Session["OrderCode1"] = invNo; } MyCmd.CommandText = "insert into tQuotationDetails (QuotationId,ItemId,Quantity,Price,InvoiceNo) values('" + OrderCode.ToString() + "', '" + Session["ProCode"].ToString() + "','" + Session["Qty"].ToString() + "','" + price.ToString() + "','" + invNo + "')"; int i = MyCmd.ExecuteNonQuery(); if (i > 0) { Session["OrderCode"] = "hh"; } MyCon.Close(); //Msg.Text = "Order is done"; } Session.Remove("Cart"); OrderCode = 0; Session.Remove("OrderCode"); Session["Amount"] = txtTotal.Text; Response.Redirect("Checkout.aspx"); }
protected void BtnEdit_Click(object sender, EventArgs e) { accountantCls.Cmd.Connection.ConnectionString = accountantCls.GetConnStr(); //Random rnum = new Random(); //int randomNumber = rnum.Next(100000000, 999999999); //int randomNumber1 = rnum.Next(100000000, 999999999); //if (FileUpload1.HasFile) //{ // string myFilePath = Server.MapPath("ProductImages/" + FileUpload1.FileName); // string ext = Path.GetExtension(myFilePath); // FileUpload1.SaveAs(Server.MapPath("ProductImages/" + randomNumber.ToString() + randomNumber1.ToString() + ext)); // Session["url"] = "ProductImages/" + randomNumber.ToString() + randomNumber1.ToString() + ext; //} //else //{ // if (H1.NavigateUrl == null) // { // Session["url"] = "ProductImages/no-image-available.png"; // } // else // { // Session["url"] = H1.NavigateUrl; // } //} string url = ""; Class_ImageResize ClsImage = new Class_ImageResize(); LblMessage.Text = ""; if (FileUpload1.HasFile) // CHECK IF ANY FILE HAS BEEN SELECTED. { HttpFileCollection hfc = Request.Files; if (hfc.Count <= 10) // 10 FILES RESTRICTION. { for (int i = 0; i <= hfc.Count - 1; i++) { HttpPostedFile hpf = hfc[i]; url = ClsImage.imageresize(hpf); } LblMessage.Text += "<br> Total <b>" + hfc.Count + "</b> file(s) "; } else { LblMessage.Text = "Max. 10 files allowed."; } } else { url = H1.NavigateUrl; } try { accountantCls.Cmd.CommandType = CommandType.StoredProcedure; accountantCls.Cmd.CommandText = "USP_Item_Edit"; accountantCls.Cmd.Parameters.Add("ItemId", SqlDbType.Int).Value = Session["ProductId"].ToString(); accountantCls.Cmd.Parameters.Add("CompanyId", SqlDbType.Int).Value = Session["CompanyId"].ToString(); //accountantCls.Cmd.Parameters.Add("BranchId", SqlDbType.Int).Value = Session["BranchId"].ToString(); if (TreeView1.SelectedNode != null) { accountantCls.Cmd.Parameters.Add("ItemGroupId", SqlDbType.Int).Value = TreeView1.SelectedNode.Value; } else { accountantCls.Cmd.Parameters.Add("ItemGroupId", SqlDbType.Int).Value = Session["CategoryId"].ToString().Trim(); } accountantCls.Cmd.Parameters.Add("Level", SqlDbType.Int).Value = Level; accountantCls.Cmd.Parameters.Add("ItemCode", SqlDbType.NVarChar).Value = TxtProductCode.Text; accountantCls.Cmd.Parameters.Add("ItemName", SqlDbType.NVarChar).Value = TxtProductName.Text; accountantCls.Cmd.Parameters.Add("ProductNameEng", SqlDbType.NVarChar).Value = TxtProductNameEng.Text; accountantCls.Cmd.Parameters.Add("ItemLocation", SqlDbType.NVarChar).Value = TxtLocation.Text; accountantCls.Cmd.Parameters.Add("BasicUnit", SqlDbType.Int).Value = DropDownListUnitName.SelectedValue; accountantCls.Cmd.Parameters.Add("UserId", SqlDbType.Int).Value = Session["UserCode"].ToString(); accountantCls.Cmd.Parameters.Add("IsActive", SqlDbType.NChar).Value = RadioButtonListActive.SelectedValue; accountantCls.Cmd.Parameters.Add("@IsVAT", SqlDbType.NChar).Value = DropDownListVATvalue.SelectedValue; accountantCls.Cmd.Parameters.Add("ItemType", SqlDbType.Int).Value = DropDownListWeight.SelectedValue; accountantCls.Cmd.Parameters.Add("AgentCode", SqlDbType.Int).Value = DropDownList2.SelectedValue; accountantCls.Cmd.Parameters.Add("ImageURL", SqlDbType.NVarChar).Value = url; accountantCls.Cmd.Parameters.Add("IsDisplayed", SqlDbType.NVarChar).Value = RadioButtonListIsDisplayed.SelectedValue; accountantCls.Cmd.Parameters.Add("Details", SqlDbType.NVarChar).Value = TxtDetails.Text; accountantCls.Cmd.Parameters.Add("OrderQuantity", SqlDbType.Int).Value = TxtOrderQuantity.Text; accountantCls.Cmd.Parameters.Add("LeastQuantity", SqlDbType.Int).Value = TxtLeastQuantity.Text; accountantCls.beginTrans(); accountantCls.Cmd.ExecuteNonQuery(); accountantCls.Cmd.Parameters.Clear(); accountantCls.Cmd.CommandText = "USP_Item_Pricing_Edit"; accountantCls.Cmd.Parameters.Add("ItemId", SqlDbType.Int).Value = Session["ProductId"].ToString(); accountantCls.Cmd.Parameters.Add("FillQuantity", SqlDbType.Decimal).Value = TxtAvaiableQuantity.Text; accountantCls.Cmd.Parameters.Add("CostPrice", SqlDbType.Decimal).Value = TxtPrice.Text; accountantCls.Cmd.Parameters.Add("AveragePrice", SqlDbType.Decimal).Value = TxtAveragePrice.Text; accountantCls.Cmd.Parameters.Add("SalePrice", SqlDbType.Decimal).Value = TxtSalePrice.Text; accountantCls.Cmd.Parameters.Add("MinSalePrice", SqlDbType.Decimal).Value = TxtMinSalePrice.Text; accountantCls.Cmd.Parameters.Add("WholeSalePrice", SqlDbType.Decimal).Value = TxtWholeSalePrice.Text; accountantCls.Cmd.Parameters.Add("OutSidePrice", SqlDbType.Decimal).Value = TxtOutSidePrice.Text; accountantCls.Cmd.Parameters.Add("BarCode", SqlDbType.NVarChar).Value = TxtBarcode.Text; accountantCls.Cmd.Parameters.Add("OfferPrice", SqlDbType.Decimal).Value = TxtOfferPrice.Text; accountantCls.Cmd.ExecuteNonQuery(); accountantCls.commitTrans(); } catch (Exception ex) { accountantCls.rollBackTrans(); } BindProduct(); }
protected void BtnEdit_Click(object sender, EventArgs e) { accountantCls.Cmd.Connection.ConnectionString = accountantCls.GetConnStr(); int RecordId = 0; try { accountantCls.Cmd.CommandType = CommandType.StoredProcedure; accountantCls.Cmd.CommandText = "USP_Item_Pricing_Select_Summ"; accountantCls.Cmd.Parameters.Add("@ItemId", SqlDbType.Int).Value = Session["ProductId"].ToString(); accountantCls.beginTrans(); RecordId = Convert.ToInt32(accountantCls.Cmd.ExecuteScalar()); } catch (Exception ex) { } string url = ""; Class_ImageResize ClsImage = new Class_ImageResize(); LblMessage.Text = ""; if (FileUpload1.HasFile) // CHECK IF ANY FILE HAS BEEN SELECTED. { HttpFileCollection hfc = Request.Files; if (hfc.Count <= 10) // 10 FILES RESTRICTION. { for (int i = 0; i <= hfc.Count - 1; i++) { HttpPostedFile hpf = hfc[i]; url = ClsImage.imageresize(hpf); } LblMessage.Text += "<br> Total <b>" + hfc.Count + "</b> file(s) "; } else { LblMessage.Text = "Max. 10 files allowed."; } } else { url = H1.NavigateUrl; } try { accountantCls.Cmd.CommandType = CommandType.StoredProcedure; accountantCls.Cmd.CommandText = "USP_Item_Edit_Summ"; accountantCls.Cmd.Parameters.Clear(); accountantCls.Cmd.Parameters.Add("@ItemId", SqlDbType.Int).Value = Session["ProductId"].ToString(); accountantCls.Cmd.Parameters.Add("@ItemCode", SqlDbType.NVarChar).Value = TxtProductCode.Text; accountantCls.Cmd.Parameters.Add("@ItemName", SqlDbType.NVarChar).Value = TxtProductName.Text; accountantCls.Cmd.Parameters.Add("@ProductNameEng", SqlDbType.NVarChar).Value = TxtProductNameEng.Text; accountantCls.Cmd.Parameters.Add("@BasicUnit", SqlDbType.Int).Value = DropDownListUnitName.SelectedValue; accountantCls.Cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Session["UserCode"].ToString(); accountantCls.Cmd.Parameters.Add("@IsActive", SqlDbType.NChar).Value = RadioButtonListActive.SelectedValue; accountantCls.Cmd.Parameters.Add("@IsVAT", SqlDbType.NChar).Value = DropDownListVATvalue.SelectedValue; accountantCls.Cmd.Parameters.Add("@ImageURL", SqlDbType.NVarChar).Value = url; accountantCls.Cmd.Parameters.Add("@IsDisplayed", SqlDbType.NVarChar).Value = RadioButtonListIsDisplayed.SelectedValue; accountantCls.Cmd.Parameters.Add("@Details", SqlDbType.NVarChar).Value = TxtDetails.Text; accountantCls.Cmd.Parameters.Add("@OrderQuantity", SqlDbType.Int).Value = TxtOrderQuantity.Text; accountantCls.Cmd.Parameters.Add("@LeastQuantity", SqlDbType.Int).Value = TxtLeastQuantity.Text; accountantCls.Cmd.ExecuteNonQuery(); accountantCls.Cmd.Parameters.Clear(); if (RecordId > 0) { accountantCls.Cmd.CommandText = "USP_Item_Pricing_Edit_Summ"; accountantCls.Cmd.Parameters.Add("ItemId", SqlDbType.Int).Value = Session["ProductId"].ToString(); accountantCls.Cmd.Parameters.Add("FillQuantity", SqlDbType.Decimal).Value = TxtAvaiableQuantity.Text; accountantCls.Cmd.Parameters.Add("CostPrice", SqlDbType.Decimal).Value = TxtPrice.Text; accountantCls.Cmd.Parameters.Add("SalePrice", SqlDbType.Decimal).Value = TxtSalePrice.Text; accountantCls.Cmd.Parameters.Add("MinSalePrice", SqlDbType.Decimal).Value = TxtMinSalePrice.Text; accountantCls.Cmd.Parameters.Add("WholeSalePrice", SqlDbType.Decimal).Value = TxtWholeSalePrice.Text; accountantCls.Cmd.Parameters.Add("OutSidePrice", SqlDbType.Decimal).Value = TxtOutSidePrice.Text; accountantCls.Cmd.Parameters.Add("OfferPrice", SqlDbType.Decimal).Value = TxtOfferPrice.Text; } else { accountantCls.Cmd.Parameters.Clear(); accountantCls.Cmd.CommandText = "USP_Item_Pricing"; accountantCls.Cmd.Parameters.Add("@ItemId", SqlDbType.Int).Value = Session["ProductId"].ToString(); accountantCls.Cmd.Parameters.Add("@FillQuantity", SqlDbType.Int).Value = TxtAvaiableQuantity.Text; accountantCls.Cmd.Parameters.Add("@CostPrice", SqlDbType.Decimal).Value = TxtPrice.Text; accountantCls.Cmd.Parameters.Add("@AveragePrice", SqlDbType.Decimal).Value = 0; accountantCls.Cmd.Parameters.Add("@SalePrice", SqlDbType.Decimal).Value = TxtSalePrice.Text; accountantCls.Cmd.Parameters.Add("@MinSalePrice", SqlDbType.Decimal).Value = TxtMinSalePrice.Text; accountantCls.Cmd.Parameters.Add("@WholeSalePrice", SqlDbType.Decimal).Value = TxtWholeSalePrice.Text; accountantCls.Cmd.Parameters.Add("@OutSidePrice", SqlDbType.Int).Value = TxtOutSidePrice.Text; accountantCls.Cmd.Parameters.Add("@BarCode", SqlDbType.NVarChar).Value = 0; accountantCls.Cmd.Parameters.Add("@OfferPrice", SqlDbType.Decimal).Value = TxtOfferPrice.Text; } accountantCls.Cmd.ExecuteNonQuery(); accountantCls.commitTrans(); } catch (Exception ex) { accountantCls.rollBackTrans(); } BindProduct(); }
protected void BtnSave_Click(object sender, EventArgs e) { accountantCls.Cmd.Connection.ConnectionString = accountantCls.GetConnStr(); accountantCls.beginTrans(); //accountantCls.Cmd.Connection.Open(); accountantCls.Cmd.CommandText = "select * from tItems where ItemCode=N'" + TxtProductCode.Text + "'"; SqlDataReader Reader = accountantCls.Cmd.ExecuteReader(); if (Reader.Read()) { LblMessage.Text = "Already exists"; return; } Reader.Close(); string url = ""; Class_ImageResize ClsImage = new Class_ImageResize(); LblMessage.Text = ""; if (FileUpload1.HasFile) // CHECK IF ANY FILE HAS BEEN SELECTED. { HttpFileCollection hfc = Request.Files; if (hfc.Count <= 10) // 10 FILES RESTRICTION. { for (int i = 0; i <= hfc.Count - 1; i++) { HttpPostedFile hpf = hfc[i]; url = ClsImage.imageresize(hpf); } LblMessage.Text += "<br> Total <b>" + hfc.Count + "</b> file(s) "; } else { LblMessage.Text = "Max. 10 files allowed."; } } else { url = "UploadedImages/no-image-available.png"; } try { accountantCls.Cmd.CommandType = CommandType.StoredProcedure; accountantCls.Cmd.CommandText = "USP_Item_Save"; accountantCls.Cmd.Parameters.Add("@ItemId", SqlDbType.Int).Value = 0; accountantCls.Cmd.Parameters.Add("@CompanyId", SqlDbType.Int).Value = int.Parse(Session["CompanyId"].ToString()); // accountantCls.Cmd.Parameters.Add("@BranchId", SqlDbType.Int).Value = Session["BranchId"].ToString(); accountantCls.Cmd.Parameters.Add("@ItemGroupId", SqlDbType.Int).Value = TreeView1.SelectedNode.Value; accountantCls.Cmd.Parameters.Add("@Level", SqlDbType.Int).Value = Level; accountantCls.Cmd.Parameters.Add("@ItemCode", SqlDbType.NVarChar).Value = TxtProductCode.Text; accountantCls.Cmd.Parameters.Add("@ItemName", SqlDbType.NVarChar).Value = TxtProductName.Text; accountantCls.Cmd.Parameters.Add("@ProductNameEng", SqlDbType.NVarChar).Value = TxtProductNameEng.Text; accountantCls.Cmd.Parameters.Add("@ItemLocation", SqlDbType.NVarChar).Value = TxtLocation.Text; accountantCls.Cmd.Parameters.Add("@BasicUnit", SqlDbType.Int).Value = DropDownListUnitName.SelectedValue; accountantCls.Cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Session["UserCode"].ToString(); accountantCls.Cmd.Parameters.Add("@IsActive", SqlDbType.NChar).Value = RadioButtonListActive.SelectedValue; accountantCls.Cmd.Parameters.Add("@VAT_Id", SqlDbType.NChar).Value = DropDownListVATvalue.SelectedValue; accountantCls.Cmd.Parameters.Add("@ItemType", SqlDbType.Int).Value = DropDownListWeight.SelectedValue; accountantCls.Cmd.Parameters.Add("@AgentCode", SqlDbType.Int).Value = DropDownList2.SelectedValue; accountantCls.Cmd.Parameters.Add("@ImageURL", SqlDbType.NVarChar).Value = url; accountantCls.Cmd.Parameters.Add("@IsDisplayed", SqlDbType.NVarChar).Value = RadioButtonListIsDisplayed.SelectedValue; accountantCls.Cmd.Parameters.Add("@Details", SqlDbType.NVarChar).Value = TxtDetails.Text; accountantCls.Cmd.Parameters.Add("@OrderQuantity", SqlDbType.Int).Value = TxtOrderQuantity.Text; accountantCls.Cmd.Parameters.Add("@LeastQuantity", SqlDbType.Int).Value = TxtLeastQuantity.Text; int RecordId = Convert.ToInt32(accountantCls.Cmd.ExecuteScalar()); accountantCls.Cmd.Parameters.Clear(); accountantCls.Cmd.CommandText = "USP_Item_Pricing"; accountantCls.Cmd.Parameters.Add("@ItemId", SqlDbType.Int).Value = RecordId; accountantCls.Cmd.Parameters.Add("@FillQuantity", SqlDbType.Int).Value = TxtAvaiableQuantity.Text; accountantCls.Cmd.Parameters.Add("@CostPrice", SqlDbType.Decimal).Value = TxtPrice.Text; accountantCls.Cmd.Parameters.Add("@AveragePrice", SqlDbType.Decimal).Value = TxtAveragePrice.Text; accountantCls.Cmd.Parameters.Add("@SalePrice", SqlDbType.Decimal).Value = TxtSalePrice.Text; accountantCls.Cmd.Parameters.Add("@MinSalePrice", SqlDbType.Decimal).Value = TxtMinSalePrice.Text; accountantCls.Cmd.Parameters.Add("@WholeSalePrice", SqlDbType.Decimal).Value = TxtWholeSalePrice.Text; accountantCls.Cmd.Parameters.Add("@OutSidePrice", SqlDbType.Int).Value = TxtOutSidePrice.Text; accountantCls.Cmd.Parameters.Add("@BarCode", SqlDbType.NVarChar).Value = TxtBarcode.Text; accountantCls.Cmd.Parameters.Add("@OfferPrice", SqlDbType.NVarChar).Value = TxtOfferPrice.Text; accountantCls.Cmd.ExecuteNonQuery(); accountantCls.commitTrans(); } catch (Exception ex) { accountantCls.rollBackTrans(); LblMessage.Text = ex.Message.ToString(); } }