public Guid InsertVoucherInformation(VoucherInformationBLL obj, SqlTransaction tran) { string strSql = "spInsertVoucherInformation"; SqlConnection conn = Connection.getConnection(); SqlParameter[] arPar = new SqlParameter[12]; arPar[0] = new SqlParameter("@DepositRequestId", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.DepositRequestId; arPar[1] = new SqlParameter("@VoucherNo", SqlDbType.NVarChar, 50); arPar[1].Value = obj.VoucherNo; arPar[2] = new SqlParameter("@CoffeeTypeId", SqlDbType.UniqueIdentifier); arPar[2].Value = obj.CoffeeTypeId; arPar[3] = new SqlParameter("@SpecificArea", SqlDbType.NVarChar); arPar[3].Value = obj.SpecificArea; arPar[4] = new SqlParameter("@NumberOfBags", SqlDbType.Int); arPar[4].Value = obj.NumberofBags; arPar[5] = new SqlParameter("@NumberOfPlomps", SqlDbType.Int); arPar[5].Value = obj.NumberOfPlomps; arPar[6] = new SqlParameter("@NumberOfPlompsTrailer", SqlDbType.Int); arPar[6].Value = obj.NumberOfPlompsTrailer; arPar[7] = new SqlParameter("@CertificateNo", SqlDbType.NVarChar, 50); arPar[7].Value = obj.CertificateNo; arPar[8] = new SqlParameter("@CreatedBy", SqlDbType.UniqueIdentifier); arPar[8].Value = obj.CreatedBy; arPar[9] = new SqlParameter("@CreatedDate", SqlDbType.DateTime); arPar[9].Value = DateTime.Now; arPar[10] = new SqlParameter("@Status", SqlDbType.Int); arPar[10].Value = obj.Status; arPar[11] = new SqlParameter("@VoucherId", SqlDbType.UniqueIdentifier); arPar[11].Direction = ParameterDirection.Output; int AffectedRows; Guid VoucherId = Guid.Empty; try { AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar); if (AffectedRows == -1) { VoucherId = new Guid(arPar[11].Value.ToString()); } } catch (Exception ex) { throw new Exception("Unable to insert the database.", ex); } return(VoucherId); }
public bool UpdateVoucherInformation(VoucherInformationBLL obj, SqlTransaction tran) { string strSql = "spUpdateVoucherInformation"; SqlParameter[] arPar = new SqlParameter[10]; // for Selecting the for Update arPar[0] = new SqlParameter("@VoucherId", SqlDbType.UniqueIdentifier); arPar[0].Value = obj.Id; arPar[1] = new SqlParameter("@VoucherNo", SqlDbType.NVarChar, 50); arPar[1].Value = obj.VoucherNo; arPar[2] = new SqlParameter("@CoffeeTypeId", SqlDbType.UniqueIdentifier); arPar[2].Value = obj.CoffeeTypeId; arPar[3] = new SqlParameter("@SpecificArea", SqlDbType.NVarChar); arPar[3].Value = obj.SpecificArea; arPar[4] = new SqlParameter("@NumberOfBags", SqlDbType.Int); arPar[4].Value = obj.NumberofBags; arPar[5] = new SqlParameter("@NumberOfPlomps", SqlDbType.Int); arPar[5].Value = obj.NumberOfPlomps; arPar[6] = new SqlParameter("@NumberOfPlompsTrailer", SqlDbType.Int); arPar[6].Value = obj.NumberOfPlompsTrailer; arPar[7] = new SqlParameter("@CertificateNo", SqlDbType.NVarChar); arPar[7].Value = obj.CertificateNo; arPar[8] = new SqlParameter("@LastModifiedBy", SqlDbType.UniqueIdentifier); arPar[8].Value = obj.LastModifiedBy; arPar[9] = new SqlParameter("@Status", SqlDbType.Int); arPar[9].Value = obj.Status; int AffectedRows; try { AffectedRows = SqlHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, strSql, arPar); } catch { throw new Exception("Can not update database."); } return(AffectedRows == 1); }
private void rptSampleTicketCoffee_DataInitialize(object sender, EventArgs e) { this.txtDateGenerated.Text = DateTime.Today.ToString("dd MMM-yyyy"); //Load Sample ticket with data. if (HttpContext.Current.Session["Sample"] != null) { SamplingBLL objSampling = new SamplingBLL(); objSampling = (SamplingBLL)HttpContext.Current.Session["Sample"]; objSampling = objSampling.GetSampleDetail(objSampling.Id); this.txtDateSampled.Text = objSampling.GeneratedTimeStamp.ToString("dd MMM-yyyy"); this.txtCode.Text = objSampling.SampleCode.ToString(); EmployeeAttendanceBLL objEmployee = new EmployeeAttendanceBLL(); this.txtSamplerName.Text = UserRightBLL.GetUserNameByUserId(objSampling._sampler.SamplerId); VoucherInformationBLL objVoucher = new VoucherInformationBLL(); objVoucher = objVoucher.GetVoucherInformationByCommodityDepositRequestId(objSampling.ReceivigRequestId); if (objVoucher != null) { this.txtNoBags.Text = objVoucher.NumberofBags.ToString(); this.txtPlompTruck.Text = objVoucher.NumberOfPlomps.ToString(); this.txtPlompTrailer.Text = objVoucher.NumberOfPlompsTrailer.ToString(); } //Get Driver information. List <DriverInformationBLL> list = new List <DriverInformationBLL>(); DriverInformationBLL obj = new DriverInformationBLL(); list = obj.GetActiveDriverInformationByReceivigRequestId(objSampling.ReceivigRequestId); if (list != null) { if (list.Count == 1) { obj = list[0]; this.txtPlateNo.Text = obj.PlateNumber.ToString(); this.txtTrailerPlateNo.Text = obj.TrailerPlateNumber.ToString(); } } } HttpContext.Current.Session["Sample"] = null; HttpContext.Current.Session["Sampler"] = null; }
private void LoadVoucherInformation(Guid Commoditydepositid) { VoucherInformationBLL objVoucher = new VoucherInformationBLL(); objVoucher = objVoucher.GetVoucherInformationByCommodityDepositRequestId(Commoditydepositid); if (objVoucher != null) { if (objVoucher.Id != null) { hfVoucherId.Value = objVoucher.Id.ToString(); } else { this.lblmsg.Text = "Unable to get Voucher information"; return; } } else { this.lblmsg.Text = "Unable to get Voucher information"; return; } }
protected void btnSave_Click(object sender, EventArgs e) { this.lblMessage.Text = ""; Boolean isSaved = false; Guid Id, CommodityDepositeRequest; Guid CoffeeId; string CertificateNumber, VoucherNo, SpecificArea; int NumberOfBags, NumberOfPlomps, TrailerNumberOfPlomps, Status; CoffeeId = new Guid(this.cboCoffeeType.SelectedValue.ToString()); string TranNo; try { TranNo = Request.QueryString["TranNo"]; } catch { this.lblMessage.Text = "All Required variables are not set please try again."; return; } NumberOfBags = Convert.ToInt32(this.txtNumberOfBags.Text); try { NumberOfPlomps = Convert.ToInt32(this.txtNoPlomps.Text); } catch { NumberOfPlomps = 0; } try { TrailerNumberOfPlomps = Convert.ToInt32(this.txtTrailerNoPlomps.Text); } catch { TrailerNumberOfPlomps = 0; } CertificateNumber = this.txtCertificateNo.Text; SpecificArea = this.txtSpecificArea.Text; VoucherNo = this.txtVoucherNo.Text; Status = (int)VoucherStatus.Active; // Voucher is entered as Active. Guid User = UserBLL.GetCurrentUser(); VoucherInformationBLL objVoucher = new VoucherInformationBLL(); try { if (this.btnSave.Text == "Save") { if (this.CommodityDepositRequestId.Value == null) { //TODO Get From Tracking No this.lblMessage.Text = "Unable To get Commmodity Deposite Request id.Please try again."; return; } try { CommodityDepositeRequest = new Guid(this.CommodityDepositRequestId.Value.ToString()); } catch { //TODO Get From Tracking No this.lblMessage.Text = "Unable To get Commmodity Deposite Request id.Please try again."; return; } try { isSaved = objVoucher.Save(CommodityDepositeRequest, VoucherNo, CoffeeId, SpecificArea, NumberOfBags, NumberOfPlomps, TrailerNumberOfPlomps, CertificateNumber, User, Status, TranNo); } catch (Exception ex) { this.lblMessage.Text = ex.Message; return; } if (isSaved == true) { this.btnSave.Text = "Update"; this.lblMessage.Text = "Record Added Successfully"; this.btnNext.Enabled = true; BindData(CommodityDepositeRequest); isSaved = false; this.btnNext.Enabled = true; } else { this.lblMessage.Text = "Unable to add the voucher information."; isSaved = false; } } else if (this.btnSave.Text == "Update") { Guid RecReqId = new Guid(this.CommodityDepositRequestId.Value.ToString()); Id = new Guid(this.VoucherId.Value.ToString()); isSaved = false; try { isSaved = objVoucher.Update(Id, RecReqId, VoucherNo, CoffeeId, SpecificArea, NumberOfBags, NumberOfPlomps, TrailerNumberOfPlomps, CertificateNumber, User, Status); if (isSaved == true) { this.lblMessage.Text = "Record Updated Successfully"; isSaved = false; } else { this.lblMessage.Text = "Unable to Update the Record."; isSaved = false; } } catch (GRNNotOnUpdateStatus exGRN) { this.lblMessage.Text = exGRN.msg; } catch (Exception ex) { throw ex; } } } catch (Exception ex) { throw ex; } }
public static VoucherInformationBLL getVoucherInformationByDepositRequestId(Guid Id) { VoucherInformationBLL objVoucherInformation = null; string strSql = "spGetVoucherInformationByDepositRequestId"; SqlParameter[] arPar = new SqlParameter[1]; arPar[0] = new SqlParameter("@Id", SqlDbType.UniqueIdentifier); arPar[0].Value = Id; DataSet dsResult = null; SqlConnection conn = Connection.getConnection(); try { dsResult = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, strSql, arPar); if (dsResult.Tables[0].Rows.Count == 1) { objVoucherInformation = new VoucherInformationBLL(); if (dsResult.Tables[0].Rows[0]["VoucherId"] != null) { objVoucherInformation.Id = new Guid(dsResult.Tables[0].Rows[0]["VoucherId"].ToString()); } if (dsResult.Tables[0].Rows[0]["DepositRequestId"] != null) { objVoucherInformation.DepositRequestId = new Guid(dsResult.Tables[0].Rows[0]["DepositRequestId"].ToString()); } objVoucherInformation.VoucherNo = dsResult.Tables[0].Rows[0]["VoucherNo"].ToString(); if (dsResult.Tables[0].Rows[0]["CoffeeTypeId"] != null) { objVoucherInformation.CoffeeTypeId = new Guid(dsResult.Tables[0].Rows[0]["CoffeeTypeId"].ToString()); } objVoucherInformation.SpecificArea = dsResult.Tables[0].Rows[0]["SpecificArea"].ToString(); if (dsResult.Tables[0].Rows[0]["NumberOfBags"] != null) { objVoucherInformation.NumberofBags = int.Parse(dsResult.Tables[0].Rows[0]["NumberOfBags"].ToString()); } if (dsResult.Tables[0].Rows[0]["NumberOfPlomps"] != null) { objVoucherInformation.NumberOfPlomps = int.Parse(dsResult.Tables[0].Rows[0]["NumberOfPlomps"].ToString()); } if (dsResult.Tables[0].Rows[0]["NumberOfPlompsTrailer"] != null) { objVoucherInformation.NumberOfPlompsTrailer = int.Parse(dsResult.Tables[0].Rows[0]["NumberOfPlompsTrailer"].ToString()); } objVoucherInformation.CertificateNo = dsResult.Tables[0].Rows[0]["CertificateNo"].ToString(); } } catch (Exception e) { throw e; } finally { if (conn != null) { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(objVoucherInformation); }