private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (dgvProductDetails.SelectedRows.Count == 0) { clsUtility.ShowInfoMessage("Select a bill from the given list.", clsUtility.strProjectTitle); return; } string InvoiceID = dgvProductDetails.SelectedRows[0].Cells["id"].Value.ToString(); Report.frmSalesInvoiceReport frmSalesInvoice = new Report.frmSalesInvoiceReport(); frmSalesInvoice.InvoiceID = Convert.ToInt32(InvoiceID); frmSalesInvoice.IsDirectPrint = false; frmSalesInvoice.Show(); }
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (cmbInvoice.SelectedIndex == -1) { clsUtility.ShowInfoMessage("Select a bill from the given list.", clsUtility.strProjectTitle); return; } DataTable dataTable = ObjCon.ExecuteSelectStatement("SELECT ID FROM " + clsUtility.DBName + ".dbo.SalesInvoiceDetails WITH(NOLOCK) WHERE InvoiceNumber='" + cmbInvoice.Text + "'"); if (dataTable.Rows.Count == 0) { clsUtility.ShowInfoMessage("No Invoice found for Invoice Number: " + txtOldInvoiceNumber.Text, clsUtility.strProjectTitle); return; } else { string InvoiceID = dataTable.Rows[0]["ID"].ToString(); Report.frmSalesInvoiceReport frmSalesInvoice = new Report.frmSalesInvoiceReport(); frmSalesInvoice.InvoiceID = Convert.ToInt32(InvoiceID); frmSalesInvoice.IsDirectPrint = false; frmSalesInvoice.ShowDialog(); } }
private void btnAdd_Click_1(object sender, EventArgs e) { if (SalesValidation()) { dgvProductDetails.EndEdit(); // Before sales invocing make sure you have available qty for particular store string InvoiceDateTime = dtpSalesDate.Value.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss"); GenerateInvoiceNumber(); #region SalesInvoiceDetails ObjDAL.SetColumnData("InvoiceNumber", SqlDbType.NVarChar, txtInvoiceNumber.Text); ObjDAL.SetColumnData("InvoiceDate", SqlDbType.DateTime, InvoiceDateTime); ObjDAL.SetColumnData("SubTotal", SqlDbType.Decimal, txtSubTotal.Text); ObjDAL.SetColumnData("Discount", SqlDbType.Decimal, txtDiscount.Text); ObjDAL.SetColumnData("Tax", SqlDbType.Decimal, txtDeliveryCharges.Text); ObjDAL.SetColumnData("GrandTotal", SqlDbType.Decimal, txtGrandTotal.Text); ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); ObjDAL.SetColumnData("CustomerID", SqlDbType.Int, txtCustomerID.Text); ObjDAL.SetColumnData("SalesMan", SqlDbType.Int, txtEmpID.Text); ObjDAL.SetColumnData("ShopeID", SqlDbType.Int, cmbShop.SelectedValue.ToString()); ObjDAL.SetColumnData("PaymentMode", SqlDbType.NVarChar, lblPMode.Text); ObjDAL.SetColumnData("PaymentAutoID", SqlDbType.Int, Other_Forms.frmPayment.strPaymentAutoID); int InvoiceID = ObjDAL.InsertData(clsUtility.DBName + ".dbo.SalesInvoiceDetails", true); #endregion for (int i = 0; i < dgvProductDetails.Rows.Count; i++) { string Total = dgvProductDetails.Rows[i].Cells["Total"].Value.ToString(); string ProductID = dgvProductDetails.Rows[i].Cells["ProductID"].Value.ToString(); string QTY = dgvProductDetails.Rows[i].Cells["QTY"].Value.ToString(); string Rate = dgvProductDetails.Rows[i].Cells["Rate"].Value.ToString(); string ColorID = dgvProductDetails.Rows[i].Cells["ColorID"].Value.ToString(); string SizeID = dgvProductDetails.Rows[i].Cells["SizeID"].Value.ToString(); ObjDAL.SetColumnData("InvoiceID", SqlDbType.Int, InvoiceID); ObjDAL.SetColumnData("ProductID", SqlDbType.Int, ProductID); ObjDAL.SetColumnData("QTY", SqlDbType.Decimal, QTY); ObjDAL.SetColumnData("CreatedBy", SqlDbType.Int, clsUtility.LoginID); ObjDAL.SetColumnData("Rate", SqlDbType.Decimal, Rate); ObjDAL.SetColumnData("ColorID", SqlDbType.Int, ColorID); ObjDAL.SetColumnData("SizeID", SqlDbType.Int, SizeID); ObjDAL.InsertData(clsUtility.DBName + ".dbo.SalesDetails", false); ObjDAL.ExecuteNonQuery("UPDATE " + clsUtility.DBName + ".dbo.ProductStockColorSizeMaster " + "SET QTY=QTY-" + QTY + " WHERE ProductID=" + ProductID + " and StoreID=" + cmbShop.SelectedValue.ToString() + " AND ColorID=" + ColorID + " AND SizeID=" + SizeID); } clsUtility.ShowInfoMessage("Data has been saved successfully.", clsUtility.strProjectTitle); ClearAll(); Button button = (Button)sender; if (button.Name == "btnPrint") { Report.frmSalesInvoiceReport frmSalesInvoice = new Report.frmSalesInvoiceReport(); frmSalesInvoice.InvoiceID = InvoiceID; frmSalesInvoice.IsDirectPrint = true; frmSalesInvoice.Show(); } else { Report.frmSalesInvoiceReport frmSalesInvoice = new Report.frmSalesInvoiceReport(); frmSalesInvoice.InvoiceID = InvoiceID; frmSalesInvoice.IsDirectPrint = false; frmSalesInvoice.Show(); } } }