protected void btnAdd_Click(object sender, EventArgs e) { try { int SubCategory = 0; string categoryName = ""; string SubCategoryName = ""; if (txtCategory.Text != "") { INV_IteamCategory iNV_IteamCategory = new INV_IteamCategory(); // iNV_IteamCategory.IteamCategoryID= int.Parse(ddlIteamCategoryID.SelectedValue); iNV_IteamCategory.IteamCategoryName = txtCategory.Text; iNV_IteamCategory.AddedBy = Profile.card_id; iNV_IteamCategory.AddedDate = DateTime.Now; iNV_IteamCategory.UpdatedBy = Profile.card_id; iNV_IteamCategory.UpdatedDate = DateTime.Now; int categoryID = INV_IteamCategoryManager.InsertINV_IteamCategory(iNV_IteamCategory); categoryName = txtCategory.Text; INV_IteamSubCategory iNV_IteamSubCategory = new INV_IteamSubCategory(); // iNV_IteamSubCategory.IteamSubCategoryID= int.Parse(ddlIteamSubCategoryID.SelectedValue); iNV_IteamSubCategory.IteamSubCategoryName = txtSubCategory.Text; iNV_IteamSubCategory.IteamCategoryID = categoryID; iNV_IteamSubCategory.AddedBy = Profile.card_id; iNV_IteamSubCategory.AddedDate = DateTime.Now; iNV_IteamSubCategory.UpdatedBy = Profile.card_id; iNV_IteamSubCategory.UpdatedDate = DateTime.Now; SubCategory = INV_IteamSubCategoryManager.InsertINV_IteamSubCategory(iNV_IteamSubCategory); SubCategoryName = txtSubCategory.Text; } else if (txtSubCategory.Text != "") { INV_IteamSubCategory iNV_IteamSubCategory = new INV_IteamSubCategory(); // iNV_IteamSubCategory.IteamSubCategoryID= int.Parse(ddlIteamSubCategoryID.SelectedValue); iNV_IteamSubCategory.IteamSubCategoryName = txtSubCategory.Text; iNV_IteamSubCategory.IteamCategoryID = int.Parse(ddlIteamCategoryID.SelectedValue); iNV_IteamSubCategory.AddedBy = Profile.card_id; iNV_IteamSubCategory.AddedDate = DateTime.Now; iNV_IteamSubCategory.UpdatedBy = Profile.card_id; iNV_IteamSubCategory.UpdatedDate = DateTime.Now; SubCategory = INV_IteamSubCategoryManager.InsertINV_IteamSubCategory(iNV_IteamSubCategory); categoryName = ddlIteamCategoryID.SelectedItem.Text; SubCategoryName = txtSubCategory.Text; } else { SubCategory = int.Parse(ddlIteamSubCategoryID.SelectedValue); categoryName = ddlIteamCategoryID.SelectedItem.Text; SubCategoryName = ddlIteamSubCategoryID.SelectedItem.Text; } string barcodes = categoryName + " ---> " + SubCategoryName + "<br/><br/>" + "<table><tr>"; int remaining = 5; for (int i = 0; i < int.Parse(txtNoOfItems.Text.Trim()); i++) { INV_Iteam iNV_Iteam = new INV_Iteam(); // iNV_Iteam.IteamID= int.Parse(ddlIteamID.SelectedValue); iNV_Iteam.CampusID = int.Parse(ddlCampusID.SelectedValue); iNV_Iteam.IteamCode = txtIteamCode.Text; iNV_Iteam.Description = txtDescription.Text; iNV_Iteam.IteamSubCategoryID = SubCategory; iNV_Iteam.Price = decimal.Parse(txtPrice.Text); iNV_Iteam.Quantity = decimal.Parse(txtQuantity.Text); iNV_Iteam.Unit = txtUnit.Text; iNV_Iteam.AddedBy = Profile.card_id; iNV_Iteam.AddedDate = DateTime.Now; iNV_Iteam.UpdatedBy = Profile.card_id; iNV_Iteam.UpdatedDate = DateTime.Now; int resutl = INV_IteamManager.InsertINV_Iteam(iNV_Iteam); if (i % 5 == 0) { barcodes += "</tr><tr>"; remaining = 4; } else { remaining--; } barcodes += "<td><div style='overflow:hidden;margin-left:-12px;width:157px; height:30px;margin-top: 28px;'><img style='margin-top:-30px' src='http://www.bcgen.com/demo/linear-dbgs.aspx?D="; barcodes+=resutl.ToString()+"'/></div></td>"; } for (int i = 0; i < remaining; i++) { barcodes += "<td></td>"; } barcodes += "</tr></table>"; lblBarCode.Text = barcodes; ItemBarcode itemBarcode = new ItemBarcode(); itemBarcode.SubCategoryID = SubCategory; itemBarcode.NoOfItem = Int32.Parse(txtNoOfItems.Text); itemBarcode.BarcodeText = barcodes; itemBarcode.AddedDate = DateTime.Now; int result = ItemBarcodeManager.InsertItemBarcode(itemBarcode); } catch (Exception ex) { } //Response.Redirect("AdminDisplayINV_Iteam.aspx"); }
public int InsertINV_IteamCategory(INV_IteamCategory iNV_IteamCategory) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("InsertINV_IteamCategory", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IteamCategoryID", SqlDbType.Int).Direction = ParameterDirection.Output; cmd.Parameters.Add("@IteamCategoryName", SqlDbType.NVarChar).Value = iNV_IteamCategory.IteamCategoryName; cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = iNV_IteamCategory.AddedBy; cmd.Parameters.Add("@AddedDate", SqlDbType.DateTime).Value = iNV_IteamCategory.AddedDate; cmd.Parameters.Add("@UpdatedBy", SqlDbType.NVarChar).Value = iNV_IteamCategory.UpdatedBy; cmd.Parameters.Add("@UpdatedDate", SqlDbType.DateTime).Value = iNV_IteamCategory.UpdatedDate; connection.Open(); int result = cmd.ExecuteNonQuery(); return (int)cmd.Parameters["@IteamCategoryID"].Value; } }
public bool UpdateINV_IteamCategory(INV_IteamCategory iNV_IteamCategory) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("UpdateINV_IteamCategory", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IteamCategoryID", SqlDbType.Int).Value = iNV_IteamCategory.IteamCategoryID; cmd.Parameters.Add("@IteamCategoryName", SqlDbType.NVarChar).Value = iNV_IteamCategory.IteamCategoryName; //cmd.Parameters.Add("@IteamCategoryName", SqlDbType.NVarChar).Value = iNV_IteamCategory.IteamCategoryName; //cmd.Parameters.Add("@IteamCategoryName", SqlDbType.NVarChar).Value = iNV_IteamCategory.IteamCategoryName; cmd.Parameters.Add("@UpdatedBy", SqlDbType.NVarChar).Value = iNV_IteamCategory.UpdatedBy; cmd.Parameters.Add("@UpdatedDate", SqlDbType.DateTime).Value = iNV_IteamCategory.UpdatedDate; connection.Open(); int result = cmd.ExecuteNonQuery(); return result == 1; } }
public INV_IteamCategory GetINV_IteamCategoryFromReader(IDataReader reader) { try { INV_IteamCategory iNV_IteamCategory = new INV_IteamCategory ( DataAccessObject.IsNULL<int>(reader["IteamCategoryID"]), DataAccessObject.IsNULL<string>(reader["IteamCategoryName"]), DataAccessObject.IsNULL<string>(reader["AddedBy"].ToString()), DataAccessObject.IsNULL<DateTime>(reader["AddedDate"]), DataAccessObject.IsNULL<string>(reader["UpdatedBy"].ToString()), DataAccessObject.IsNULL<DateTime>(reader["UpdatedDate"]) ); return iNV_IteamCategory; } catch(Exception ex) { return null; } }