public static int addGodownTransfer(godownTransfer gm) { try { List <KeyValuePair <string, object> > parameter = new List <KeyValuePair <string, object> >(); parameter.Add(new KeyValuePair <string, object>("@godownTransferId", gm.godownTransferId)); parameter.Add(new KeyValuePair <string, object>("@godownTransferDate", gm.godownTransferDate)); parameter.Add(new KeyValuePair <string, object>("@fromGodownTransfer", gm.fromGodownTransfer)); parameter.Add(new KeyValuePair <string, object>("@toGodownTransfer", gm.toGodownTransfer)); parameter.Add(new KeyValuePair <string, object>("@addedBy", gm.addedBy)); parameter.Add(new KeyValuePair <string, object>("@addedOn", gm.addedOn)); parameter.Add(new KeyValuePair <string, object>("@FinancialYearID", gm.FinancialYearID)); parameter.Add(new KeyValuePair <string, object>("@isUpdate", gm.isUpdate)); parameter.Add(new KeyValuePair <string, object>("@isDelete", gm.isDelete)); parameter.Add(new KeyValuePair <string, object>("@invoiceId", gm.invoiceId)); SqlHandler sqlH = new SqlHandler(); int listi = sqlH.ExecuteNonQueryI("[dbo].[Usp_addGodownTransfer]", parameter); int result = 0; for (int k = 0; k < gm.dtItems.Rows.Count; k++) { List <KeyValuePair <string, object> > parameter1 = new List <KeyValuePair <string, object> >(); parameter1.Add(new KeyValuePair <string, object>("@godownTransferId", gm.godownTransferId)); parameter1.Add(new KeyValuePair <string, object>("@FinancialYearID", gm.FinancialYearID)); parameter1.Add(new KeyValuePair <string, object>("@stockIdFrom", gm.dtItems.Rows[k]["stockId"])); parameter1.Add(new KeyValuePair <string, object>("@stockIdTo", gm.dtItems.Rows[k]["stockIdTo"])); parameter1.Add(new KeyValuePair <string, object>("@itemId", gm.dtItems.Rows[k]["itemId"])); parameter1.Add(new KeyValuePair <string, object>("@categoryId", gm.dtItems.Rows[k]["categoryId"])); parameter1.Add(new KeyValuePair <string, object>("@companyId", gm.dtItems.Rows[k]["companyId"])); parameter1.Add(new KeyValuePair <string, object>("@productCode", gm.dtItems.Rows[k]["productCode"])); parameter1.Add(new KeyValuePair <string, object>("@godownNameto", gm.toGodownTransfer)); parameter1.Add(new KeyValuePair <string, object>("@godownNamefrom", gm.fromGodownTransfer)); parameter1.Add(new KeyValuePair <string, object>("@batchNo", gm.dtItems.Rows[k]["batchNo"])); parameter1.Add(new KeyValuePair <string, object>("@MFGDate", Convert.ToDateTime(gm.dtItems.Rows[k]["MFD_Date"]))); parameter1.Add(new KeyValuePair <string, object>("@exprireDate", Convert.ToDateTime(gm.dtItems.Rows[k]["expireDate"]))); parameter1.Add(new KeyValuePair <string, object>("@Quantity", gm.dtItems.Rows[k]["Quantity"])); parameter1.Add(new KeyValuePair <string, object>("@unitBy", gm.dtItems.Rows[k]["unitBy"])); parameter1.Add(new KeyValuePair <string, object>("@godownTransfertemId", gm.dtItems.Rows[k]["godownTransfertemId"])); parameter1.Add(new KeyValuePair <string, object>("@isUpdate", gm.isUpdate)); parameter1.Add(new KeyValuePair <string, object>("@isDelete", gm.isDelete)); parameter1.Add(new KeyValuePair <string, object>("@addedBy", gm.addedBy)); parameter1.Add(new KeyValuePair <string, object>("@addedOn", gm.addedOn)); parameter1.Add(new KeyValuePair <string, object>("@invoiceId", gm.invoiceId)); result = +sqlH.ExecuteNonQueryI("[dbo].[Usp_addGodownTransferItem]", parameter1); } return(listi + result); } catch (Exception ae) { throw ae; }//8999501263 }
private void btnSave_Click(object sender, EventArgs e) { try { if (cmbFromGodown.SelectedIndex == 0 || cmbFromGodown.SelectedValue == null) { if (Utility.Langn == "English") { MessageBox.Show("Please select From Godown...!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("कृपया From गोडाऊन निवडा...!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } cmbFromGodown.Focus(); return; } if (cmbtoGodown.SelectedIndex == 0 || cmbtoGodown.SelectedValue == null) { if (Utility.Langn == "English") { MessageBox.Show("Please select To Godown...!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("कृपया To गोडाऊन निवडा...!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } cmbtoGodown.Focus(); return; } if (cmbFromGodown.Text.Trim() == cmbtoGodown.Text.Trim()) { if (Utility.Langn == "English") { MessageBox.Show("Please Change To Godown...!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("कृपया To गोडाऊन बदला...!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } cmbtoGodown.Focus(); return; } for (int c = 0; c < dgvGodownTransfer.Rows.Count; c++) { if (dgvGodownTransfer.Rows[c].Cells["itemName"].Value == null) { if (Utility.Langn == "English") { MessageBox.Show("Please add Item Name in list.."); } else { MessageBox.Show("कृपया लिस्ट मध्ये वस्तूचे नाव भरा.."); } dgvGodownTransfer.Focus(); dgvGodownTransfer.CurrentCell = dgvGodownTransfer.Rows[c].Cells["itemName"]; return; } if (dgvGodownTransfer.Rows[c].Cells["Quantity"].Value == null || Convert.ToDouble(dgvGodownTransfer.Rows[c].Cells["Quantity"].Value) == 0) { if (Utility.Langn == "English") { MessageBox.Show("Please add Quantity in list.."); } else { MessageBox.Show("कृपया लिस्ट मध्ये वस्तूचे नाव भरा.."); } dgvGodownTransfer.Focus(); dgvGodownTransfer.CurrentCell = dgvGodownTransfer.Rows[c].Cells["Quantity"]; return; } } godownTransfer gm = new godownTransfer(); if (isUpdate == false && isDelete == false) { gm.godownTransferId = SaleDetailsController.getMaxIdSalesItemDetails(5, Utility.FinancilaYearId); gm.invoiceId = SaleDetailsController.getMaxIdSalesItemDetails(6, Utility.FinancilaYearId); } else { gm.godownTransferId = Convert.ToInt64(txtId.Text); gm.invoiceId = Convert.ToInt64(txtInvoice.Text); } gm.godownTransferDate = dtpDate.Value; gm.fromGodownTransfer = cmbFromGodown.Text.Trim(); gm.toGodownTransfer = cmbtoGodown.Text.Trim(); gm.isDelete = isDelete; gm.isUpdate = isUpdate; DataTable dtSaleItems = new DataTable(); foreach (DataGridViewColumn col in dgvGodownTransfer.Columns) { dtSaleItems.Columns.Add(col.Name); } foreach (DataGridViewRow row in dgvGodownTransfer.Rows) { DataRow dRow = dtSaleItems.NewRow(); foreach (DataGridViewCell cell in row.Cells) { if (cell.Value == null) { if (Utility.Langn == "English") { MessageBox.Show("Please add all details in list"); } else { MessageBox.Show("कृपया लिस्ट मध्ये पूर्ण माहिती भरा"); } return; } dRow[cell.ColumnIndex] = cell.Value; } dtSaleItems.Rows.Add(dRow); } gm.dtItems = dtSaleItems; gm.FinancialYearID = Utility.FinancilaYearId; gm.addedBy = 1; gm.addedOn = dtpDate.Value; int i = 0; string msg = ""; if (isDelete == false) { if (Utility.Langn == "English") { msg = "Record Saved successfully !! "; } else { msg = "माहिती यशस्वीरित्या साठवल्या गेली !! "; } i = godownTransferController.addGodownTransfer(gm); } if (isDelete == true) { if (Utility.Langn == "English") { msg = "Record Deleted successfully!! "; } else { msg = "माहिती यशस्वीरित्या डिलीट झाली आहे!! "; } i = godownTransferController.addGodownTransfer(gm); } if (i > 0) { MessageBox.Show(msg, "जतन", MessageBoxButtons.OK, MessageBoxIcon.Information); btnnew_Click(sender, e); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }