/// <summary> /// Function to Update values in RejectionInDetails Table /// </summary> /// <param name="rejectionindetailsinfo"></param> public void RejectionInDetailsEdit(RejectionInDetailsInfo rejectionindetailsinfo) { try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RejectionInDetailsEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@rejectionInDetailsId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.RejectionInDetailsId; sprmparam = sccmd.Parameters.Add("@rejectionInMasterId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.RejectionInMasterId; sprmparam = sccmd.Parameters.Add("@deliveryNoteDetailsId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.DeliveryNoteDetailsId; sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.ProductId; sprmparam = sccmd.Parameters.Add("@qty", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.Qty; sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.Rate; sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.UnitId; sprmparam = sccmd.Parameters.Add("@unitConversionId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.UnitConversionId; sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.BatchId; sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.GodownId; sprmparam = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.RackId; sprmparam = sccmd.Parameters.Add("@amount", SqlDbType.Decimal); sprmparam.Value = rejectionindetailsinfo.Amount; sprmparam = sccmd.Parameters.Add("@slNo", SqlDbType.Int); sprmparam.Value = rejectionindetailsinfo.SlNo; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = rejectionindetailsinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = rejectionindetailsinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = rejectionindetailsinfo.Extra2; sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } }
/// <summary> /// Save or edit function /// </summary> public void SaveOrEdit() { SettingsSP spSetting = new SettingsSP(); try { decimal decIdentity = 0; DeliveryNoteMasterSP SpDeliveryNoteMaster = new DeliveryNoteMasterSP(); DeliveryNoteMasterInfo InfoDeliveryNoteMaster = new DeliveryNoteMasterInfo(); InfoDeliveryNoteMaster = SpDeliveryNoteMaster.DeliveryNoteMasterView(Convert.ToDecimal(cmbDeliveryNoteNo.SelectedValue)); RejectionInMasterInfo InfoRejectionInMaster = new RejectionInMasterInfo(); RejectionInDetailsInfo InfoRejectionInDetails = new RejectionInDetailsInfo(); RejectionInDetailsSP SpRejectionInDetails = new RejectionInDetailsSP(); StockPostingInfo InfoStockPosting = new StockPostingInfo(); StockPostingSP SpStockPosting = new StockPostingSP(); if (isAutomatic) { InfoRejectionInMaster.VoucherNo = strVoucherNo; InfoRejectionInMaster.InvoiceNo = txtRejectionInNo.Text; } else { InfoRejectionInMaster.VoucherNo = txtRejectionInNo.Text; InfoRejectionInMaster.InvoiceNo = txtRejectionInNo.Text; } InfoRejectionInMaster.VoucherTypeId = decRejectionInVoucherTypeId; InfoRejectionInMaster.SuffixPrefixId = decRejectionInSuffixPrefixId; InfoRejectionInMaster.Date = DateTime.Parse(txtDate.Text); InfoRejectionInMaster.LedgerId = Convert.ToDecimal(cmbCashorParty.SelectedValue.ToString()); InfoRejectionInMaster.PricinglevelId = cmbPricingLevel.SelectedValue == null ? 0 : Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); InfoRejectionInMaster.EmployeeId = cmbSalesMan.SelectedValue == null ? 1 : Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); InfoRejectionInMaster.Narration = txtNarration.Text.Trim(); InfoRejectionInMaster.ExchangeRateId = cmbCurrency.SelectedValue == null ? 0 : Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); InfoRejectionInMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); InfoRejectionInMaster.UserId = PublicVariables._decCurrentUserId; InfoRejectionInMaster.LrNo = txtLRNo.Text.Trim(); InfoRejectionInMaster.TransportationCompany = txtTransportationCompany.Text.Trim(); InfoRejectionInMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoRejectionInMaster.Extra1 = string.Empty; InfoRejectionInMaster.Extra2 = string.Empty; InfoRejectionInMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbDeliveryNoteNo.SelectedValue == null ? "" : cmbDeliveryNoteNo.SelectedValue.ToString()); if (decRejectionInIdToEdit == 0) { decIdentity = spRejectionInMaster.RejectionInMasterAdd(InfoRejectionInMaster); } else { InfoRejectionInMaster.RejectionInMasterId = decRejectionInIdToEdit; spRejectionInMaster.RejectionInMasterEdit(InfoRejectionInMaster); } if (decRejectionInIdToEdit == 0) { InfoRejectionInDetails.RejectionInMasterId = decIdentity; } else { SpRejectionInDetails.DeleteRejectionInDetailsByRejectionInMasterId(decRejectionInIdToEdit); SpStockPosting.DeleteStockPostingByAgnstVouTypeIdAndAgnstVouNo(decRejectionInVoucherTypeId, strVoucherNo); InfoRejectionInDetails.RejectionInMasterId = decRejectionInIdToEdit; } foreach (DataGridViewRow dgvrow in dgvProduct.Rows) { InfoRejectionInDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxDeliveryNoteDetailsId"].Value.ToString()); InfoRejectionInDetails.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString()); InfoRejectionInDetails.Qty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString()); InfoRejectionInDetails.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString()); InfoRejectionInDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); InfoRejectionInDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value.ToString());//0;//check InfoRejectionInDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString()); InfoRejectionInDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString()); InfoRejectionInDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString()); InfoRejectionInDetails.Amount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAmount"].Value.ToString()); InfoRejectionInDetails.SlNo = Convert.ToInt32(dgvrow.Cells["dgvtxtSlNo"].Value.ToString()); InfoRejectionInDetails.Extra1 = string.Empty; InfoRejectionInDetails.Extra2 = string.Empty; SpRejectionInDetails.RejectionInDetailsAdd(InfoRejectionInDetails); InfoStockPosting.Date = Convert.ToDateTime(txtDate.Text); InfoStockPosting.VoucherTypeId = InfoDeliveryNoteMaster.VoucherTypeId; InfoStockPosting.VoucherNo = InfoDeliveryNoteMaster.VoucherNo; InfoStockPosting.InvoiceNo = InfoDeliveryNoteMaster.InvoiceNo; InfoStockPosting.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString()); InfoStockPosting.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString()); InfoStockPosting.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); InfoStockPosting.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString()); InfoStockPosting.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString()); InfoStockPosting.AgainstVoucherTypeId = decRejectionInVoucherTypeId; if (isAutomatic) { InfoStockPosting.AgainstInvoiceNo = txtRejectionInNo.Text; InfoStockPosting.AgainstVoucherNo = strVoucherNo; } else { InfoStockPosting.AgainstInvoiceNo = txtRejectionInNo.Text; InfoStockPosting.AgainstVoucherNo = txtRejectionInNo.Text; } InfoStockPosting.InwardQty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString()); InfoStockPosting.OutwardQty = 0; InfoStockPosting.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString()); InfoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoStockPosting.Extra1 = string.Empty; InfoStockPosting.Extra2 = string.Empty; SpStockPosting.StockPostingAdd(InfoStockPosting); } if (decRejectionInIdToEdit == 0) { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (spSetting.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } } else { Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (spSetting.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decRejectionInIdToEdit); } else { Print(decRejectionInIdToEdit); } } this.Close(); } } catch (Exception ex) { MessageBox.Show("RI:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }