public static void addnewItemtoList(String name, decimal price, int qty) { serviceProducts sp1 = new serviceProducts(0, name, qty, price); decimal total = price * qty; billItemsGrid.Add(new billingItem(0, sp1, null, qty, total, "Service")); }
public int insertServiceProductNgetID(serviceProducts tempService) { int result = 1; try { using (SqlConnection con = new SqlConnection(conString)) { con.Open(); SqlCommand cmd = new SqlCommand("InsertServiceProd_N_GetID", con); cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@serv_ID", tempService.ServiceProID); //cmd.Parameters.AddWithValue("@serv_Code", tempService.Service_Name); cmd.Parameters.AddWithValue("@serv_Name", tempService.Service_Name); //cmd.Parameters.AddWithValue("@serv_Description", tempService.Service_Desc); cmd.Parameters.AddWithValue("@serv_Price", tempService.Service_Price); cmd.Parameters.AddWithValue("@serv_Qty", tempService._qty); decimal tmpresult = (decimal)cmd.ExecuteScalar(); result = Convert.ToInt32(tmpresult); con.Close(); } } catch (Exception e) { result = 0; logger.Error("DAL Error in ServiceProdDataAccess.insertServiceProductNgetID: " + e.Message); //Console.WriteLine("DAL Error in ServiceProdDataAccess.insertServiceProductNgetID: " + e.Message); } return(result); }
public Boolean addNewServiceProduct(serviceProducts service) { ServiceProdDataAccess spda1 = new ServiceProdDataAccess(); int insertResult = spda1.insertServiceProductNgetID(service); Console.WriteLine("Insertion Result is: " + insertResult); if (insertResult.Equals(1)) { return(true); } else { return(false); } }
public List <serviceProducts> getAllServiceProducts() { List <serviceProducts> srvcProductLst = new List <serviceProducts>(); try { using (SqlConnection con = new SqlConnection(conString)) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("GetALLServiceProds", con); cmd.CommandType = CommandType.StoredProcedure; using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { serviceProducts tmpSrvcProd = new serviceProducts(); tmpSrvcProd.Service_ID = (int)rdr["serv_ID"]; tmpSrvcProd.Service_Name = (String)rdr["serv_Name"]; //tmpSrvcProd.Service_Desc = (String)rdr["serv_Description"]; tmpSrvcProd.Service_Price = (Decimal)rdr["serv_Price"]; tmpSrvcProd._qty = (int)rdr["serv_Qty"]; srvcProductLst.Add(tmpSrvcProd); } } if (con.State == ConnectionState.Open) { con.Close(); } } } catch (Exception e) { logger.Error("DAL Error in getAllServiceProducts: " + e.Message); //Console.WriteLine("DAL Error in getAllServiceProducts: " + e.Message); } return(srvcProductLst); }
public List <billingItem> getBillingItemData(int bill_Id) { Console.WriteLine("Bill ID is: " + bill_Id); List <billingItem> billingLst = new List <billingItem>(); try { using (SqlConnection con = new SqlConnection(conString)) { if (con.State == ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand("GetBillItemsWithData", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@bill_Id", bill_Id); using (SqlDataReader rdr = cmd.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { billingItem tmpBillItm = new billingItem(); tmpBillItm.BillItemId = (int)rdr["bill_item_Id"]; tmpBillItm._type = (String)rdr["itmtype"]; tmpBillItm.Quantiy = (int)rdr["quantity"]; tmpBillItm.Total = Convert.ToDecimal(rdr["itm_total"]); if (tmpBillItm._type.Equals("Product")) { products tmpPrd = new products(); tmpPrd.ProductID = (int)rdr["prod_ID"]; tmpPrd.ProductCode = (String)rdr["prod_Code"]; tmpPrd.ProductName = (String)rdr["prod_Name"]; tmpPrd.ProductPrice = Convert.ToDecimal(rdr["prod_Price"]); tmpBillItm.Product = tmpPrd; } else if (tmpBillItm._type.Equals("Service")) { serviceProducts tmpSrvcPrd = new serviceProducts(); tmpSrvcPrd.Service_ID = (int)rdr["Serv_Id"]; Console.WriteLine("Service name id is: " + tmpSrvcPrd.Service_ID); tmpSrvcPrd.Service_Name = (String)rdr["serv_Name"]; tmpSrvcPrd.Service_Price = Convert.ToDecimal(rdr["serv_Price"]); tmpBillItm.Service = tmpSrvcPrd; } billingLst.Add(tmpBillItm); } } } if (con.State == ConnectionState.Open) { con.Close(); } } } catch (Exception e) { logger.Error("DAL Error in BillingDataAccess.getBillingItemData: " + e.ToString()); //Console.WriteLine("DAL Error in BillingDataAccess.getBillingItemData: " + e.ToString()); } return(billingLst); }
public Boolean deleteService(serviceProducts service) { return(new ServiceProdDataAccess().DeleteServiceByID(service.Service_ID)); }