/// <summary> /// Function to Update values in PurchaseOrderDetails Table /// </summary> /// <param name="purchaseorderdetailsinfo"></param> public void PurchaseOrderDetailsEdit(PurchaseOrderDetailsInfo purchaseorderdetailsinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PurchaseOrderDetailsEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@purchaseOrderDetailsId", SqlDbType.Decimal); sprmparam.Value = purchaseorderdetailsinfo.PurchaseOrderDetailsId; sprmparam = sccmd.Parameters.Add("@purchaseOrderMasterId", SqlDbType.Decimal); sprmparam.Value = purchaseorderdetailsinfo.PurchaseOrderMasterId; sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal); sprmparam.Value = purchaseorderdetailsinfo.ProductId; sprmparam = sccmd.Parameters.Add("@qty", SqlDbType.Decimal); sprmparam.Value = purchaseorderdetailsinfo.Qty; sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal); sprmparam.Value = purchaseorderdetailsinfo.Rate; sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal); sprmparam.Value = purchaseorderdetailsinfo.UnitId; sprmparam = sccmd.Parameters.Add("@unitConversionId", SqlDbType.Decimal); sprmparam.Value = purchaseorderdetailsinfo.UnitConversionId; sprmparam = sccmd.Parameters.Add("@amount", SqlDbType.Decimal); sprmparam.Value = purchaseorderdetailsinfo.Amount; sprmparam = sccmd.Parameters.Add("@slNo", SqlDbType.Int); sprmparam.Value = purchaseorderdetailsinfo.SlNo; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = purchaseorderdetailsinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = purchaseorderdetailsinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Function to get particular values from PurchaseOrderDetails Table based on the parameter /// </summary> /// <param name="purchaseOrderDetailsId"></param> /// <returns></returns> public PurchaseOrderDetailsInfo PurchaseOrderDetailsView(decimal purchaseOrderDetailsId) { PurchaseOrderDetailsInfo purchaseorderdetailsinfo = new PurchaseOrderDetailsInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PurchaseOrderDetailsView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@purchaseOrderDetailsId", SqlDbType.Decimal); sprmparam.Value = purchaseOrderDetailsId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { purchaseorderdetailsinfo.PurchaseOrderDetailsId = decimal.Parse(sdrreader[0].ToString()); purchaseorderdetailsinfo.PurchaseOrderMasterId = decimal.Parse(sdrreader[1].ToString()); purchaseorderdetailsinfo.ProductId = decimal.Parse(sdrreader[2].ToString()); purchaseorderdetailsinfo.Qty = decimal.Parse(sdrreader[3].ToString()); purchaseorderdetailsinfo.Rate = decimal.Parse(sdrreader[4].ToString()); purchaseorderdetailsinfo.UnitId = decimal.Parse(sdrreader[5].ToString()); purchaseorderdetailsinfo.UnitConversionId = decimal.Parse(sdrreader[6].ToString()); purchaseorderdetailsinfo.Amount = decimal.Parse(sdrreader[7].ToString()); purchaseorderdetailsinfo.SlNo = int.Parse(sdrreader[8].ToString()); purchaseorderdetailsinfo.ExtraDate = DateTime.Parse(sdrreader[9].ToString()); purchaseorderdetailsinfo.Extra1 = sdrreader[10].ToString(); purchaseorderdetailsinfo.Extra2 = sdrreader[11].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(purchaseorderdetailsinfo); }
/// <summary> /// Function to get particular values from PurchaseOrderDetails Table based on the parameter /// </summary> /// <param name="purchaseOrderDetailsId"></param> /// <returns></returns> public PurchaseOrderDetailsInfo PurchaseOrderDetailsView(decimal purchaseOrderDetailsId) { PurchaseOrderDetailsInfo purchaseorderdetailsinfo = new PurchaseOrderDetailsInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("PurchaseOrderDetailsView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@purchaseOrderDetailsId", SqlDbType.Decimal); sprmparam.Value = purchaseOrderDetailsId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { purchaseorderdetailsinfo.PurchaseOrderDetailsId = decimal.Parse(sdrreader[0].ToString()); purchaseorderdetailsinfo.PurchaseOrderMasterId = decimal.Parse(sdrreader[1].ToString()); purchaseorderdetailsinfo.ProductId = decimal.Parse(sdrreader[2].ToString()); purchaseorderdetailsinfo.Qty = decimal.Parse(sdrreader[3].ToString()); purchaseorderdetailsinfo.Rate = decimal.Parse(sdrreader[4].ToString()); purchaseorderdetailsinfo.UnitId = decimal.Parse(sdrreader[5].ToString()); purchaseorderdetailsinfo.UnitConversionId = decimal.Parse(sdrreader[6].ToString()); purchaseorderdetailsinfo.Amount = decimal.Parse(sdrreader[7].ToString()); purchaseorderdetailsinfo.SlNo = int.Parse(sdrreader[8].ToString()); purchaseorderdetailsinfo.ExtraDate = DateTime.Parse(sdrreader[9].ToString()); purchaseorderdetailsinfo.Extra1 = sdrreader[10].ToString(); purchaseorderdetailsinfo.Extra2 = sdrreader[11].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return purchaseorderdetailsinfo; }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo(); PurchaseOrderDetailsSP spPurchaseOrderDetails = new PurchaseOrderDetailsSP(); PurchaseOrderDetailsInfo infoPurchaseOrderDetails = new PurchaseOrderDetailsInfo(); PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP(); ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); SettingsSP spSettings = new SettingsSP(); if (cbxCancel.Checked) { infoPurchaseOrderMaster.Cancelled = true; } else { infoPurchaseOrderMaster.Cancelled = false; } infoPurchaseOrderMaster.Date = Convert.ToDateTime(txtDate.Text); infoPurchaseOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text); infoPurchaseOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); if (isAutomatic == true) { infoPurchaseOrderMaster.SuffixPrefixId = decPurchaseSuffixPrefixId; infoPurchaseOrderMaster.VoucherNo = strVoucherNo; } else { infoPurchaseOrderMaster.SuffixPrefixId = 0; infoPurchaseOrderMaster.VoucherNo = spPurchaseOrderMaster.VoucherNoMax(decPurchaseOrderTypeId); } infoPurchaseOrderMaster.VoucherTypeId = decPurchaseOrderTypeId; infoPurchaseOrderMaster.InvoiceNo = txtOrderNo.Text; infoPurchaseOrderMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseOrderMaster.EmployeeId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid infoPurchaseOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseOrderMaster.Narration = txtNarration.Text.Trim(); infoPurchaseOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoPurchaseOrderMaster.exchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoPurchaseOrderMaster.Extra1 = string.Empty; infoPurchaseOrderMaster.Extra2 = string.Empty; decPurchaseOrderMasterIdentity = Convert.ToDecimal(spPurchaseOrderMaster.PurchaseOrderMasterAdd(infoPurchaseOrderMaster)); int inRowcount = dgvPurchaseOrder.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { infoPurchaseOrderDetails.PurchaseOrderMasterId = decPurchaseOrderMasterIdentity; if (dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != "") { infoProduct = spProduct.ProductViewByCode(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoPurchaseOrderDetails.ProductId = infoProduct.ProductId; } if (dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != "") { infoPurchaseOrderDetails.Qty = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); } if (dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != "") { infoPurchaseOrderDetails.UnitId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value); infoPurchaseOrderDetails.UnitConversionId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); } infoPurchaseOrderDetails.Rate = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoPurchaseOrderDetails.Amount = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoPurchaseOrderDetails.SlNo = Convert.ToInt32(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoPurchaseOrderDetails.Extra1 = string.Empty; infoPurchaseOrderDetails.Extra2 = string.Empty; spPurchaseOrderDetails.PurchaseOrderDetailsAdd(infoPurchaseOrderDetails); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseOrderMasterIdentity); } else { Print(decPurchaseOrderMasterIdentity); } } Clear(); } catch (Exception ex) { MessageBox.Show("PO35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// edit function for PurchaseOrderDetails /// </summary> public void EditPurchaseOrderDetails() { try { ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); PurchaseOrderDetailsInfo infoPurchaseOrderDetails = new PurchaseOrderDetailsInfo(); PurchaseOrderDetailsSP spPurchaseOrderDetails = new PurchaseOrderDetailsSP(); for (int inI = 0; inI < dgvPurchaseOrder.Rows.Count - 1; inI++) { if (Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value) == 0 || dgvPurchaseOrder.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString() == null || dgvPurchaseOrder.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString() == string.Empty) { infoPurchaseOrderDetails.PurchaseOrderMasterId = decPurchaseOrderMasterId; infoProduct = spProduct.ProductViewByCode(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoPurchaseOrderDetails.ProductId = infoProduct.ProductId; infoPurchaseOrderDetails.Qty = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoPurchaseOrderDetails.UnitId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value); infoPurchaseOrderDetails.UnitConversionId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value); infoPurchaseOrderDetails.Rate = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoPurchaseOrderDetails.Amount = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoPurchaseOrderDetails.SlNo = Convert.ToInt32(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoPurchaseOrderDetails.Extra1 = string.Empty; infoPurchaseOrderDetails.Extra2 = string.Empty; spPurchaseOrderDetails.PurchaseOrderDetailsAdd(infoPurchaseOrderDetails); } else { infoPurchaseOrderDetails.PurchaseOrderMasterId = decPurchaseOrderMasterId; infoPurchaseOrderDetails.PurchaseOrderDetailsId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value); infoProduct = spProduct.ProductViewByCode(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoPurchaseOrderDetails.ProductId = infoProduct.ProductId; infoPurchaseOrderDetails.Qty = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoPurchaseOrderDetails.UnitId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoPurchaseOrderDetails.UnitConversionId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value); infoPurchaseOrderDetails.Rate = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoPurchaseOrderDetails.Amount = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoPurchaseOrderDetails.SlNo = Convert.ToInt32(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoPurchaseOrderDetails.Extra1 = string.Empty; infoPurchaseOrderDetails.Extra2 = string.Empty; spPurchaseOrderDetails.PurchaseOrderDetailsEdit(infoPurchaseOrderDetails); } } } catch (Exception ex) { MessageBox.Show("PO33:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }