private void FillEmployeeData() { objSPDB = new StockPointDB(); DataTable dtEmp = null; cbEcode.DataSource = null; cbEcode.Items.Clear(); if (cbCompany.SelectedIndex > 0 && cbBranches.SelectedIndex > 0) { try { dtEmp = objSPDB.Get_GCandAboveList(cbCompany.SelectedValue.ToString(), cbBranches.SelectedValue.ToString().Split('@')[0], CommonData.DocMonth, txtEcodeSearch.Text.ToString()); if (dtEmp.Rows.Count > 0) { cbEcode.DataSource = dtEmp; cbEcode.DisplayMember = "ENAME"; cbEcode.ValueMember = "ECODE"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (cbEcode.SelectedIndex > -1) { cbEcode.SelectedIndex = 0; strECode = ((System.Data.DataRowView)(cbEcode.SelectedItem)).Row.ItemArray[0].ToString(); } objData = null; Cursor.Current = Cursors.Default; } } }
private void btnSave_Click(object sender, EventArgs e) { objSPDB = new StockPointDB(); string sqlText = ""; int iRes = 0; objDB = new SQLDB(); if (CheckData() == true) { try { string[] sBrDetl = null; sBrDetl = cmbBranch.SelectedValue.ToString().Split('@'); string sStatus = ""; if (cmbStatus.SelectedIndex == 0) { sStatus = "R"; } else if (cmbStatus.SelectedIndex == 1) { sStatus = "C"; } if (txtArea.Text.Length == 0) { txtArea.Text = "0"; } if (txtBags.Text.Length == 0) { txtBags.Text = "0"; } if (cmbTrnType.Text.Equals("NEW")) { sqlText += "UPDATE BRANCH_MAS SET BRANCH_ADDRESS='" + txtBranchAdd.Text.ToString() + "',LOCATION='" + txtLocation.Text.ToString() + "',MANDAL='" + txtMandal.Text.ToString() + "',DISTRICT='" + txtDistrict.Text.ToString() + "',STATE='" + txtState.Text.ToString() + "',PIN='" + txtPin.Text.ToString() + "',LAST_MODIFIED_BY='" + CommonData.LogUserId + "',LAST_MODIFIED_DATE='" + Convert.ToDateTime(CommonData.CurrentDate).ToString("dd/MMM/yyyy") + "' WHERE COMPANY_CODE='" + sBrDetl[0] + "' AND BRANCH_CODE='" + sBrDetl[1] + "'"; } if (isUpdate == false) { sqlText += " UPDATE SP_RENTAL_AGRIMENTS_DETL SET SPRAD_AGGRIMENT_STATUS='C' WHERE SPRAD_BRANCH_CODE='" + sBrDetl[1] + "'"; sqlText += " INSERT INTO SP_RENTAL_AGRIMENTS_DETL(SPRAD_COMPANY_CODE" + ",SPRAD_BRANCH_CODE" + ",SPRAD_TRN_NO" + ",SPRAD_TRN_TYPE" + ",SPRAD_FROM" + ",SPRAD_TO" + ",SPRAD_GODOWN_ADDRESS" + ",SPRAD_GODOWN_LOCATION" + ",SPRAD_GODOWN_MONDAL" + ",SPRAD_GODOWN_DISTRICT" + ",SPRAD_GODOWN_STATE" + ",SPRAD_GODOWN_PIN" + ",SPRAD_AGGRIMENT_STATUS" + ",SPRAD_OWNER_NAME" + ",SPRAD_MOBILE_NO" + ",SPRAD_BANK_ACC_NO" + ",SPRAD_SD_AMT" + ",SPRAD_MTLY_RNT_AMT" + ",SPRAD_CREATED_BY" + ",SPRAD_CREATED_DATE " + ",SPRAD_REMARKS " + ",SPRAD_AREA_SFT " + ",SPRAD_CAPACITY_BAGS)" + " VALUES(" + "'" + sBrDetl[0] + "','" + sBrDetl[1] + "','" + txtTrnNo.Text.ToUpper() + "','" + cmbTrnType.Text.ToUpper() + "','" + Convert.ToDateTime(dtpFromDate.Value).ToString("dd/MMM/yyyy") + "','" + Convert.ToDateTime(dtpToDate.Value).ToString("dd/MMM/yyyy") + "','" + txtBranchAdd.Text.ToUpper() + "','" + txtLocation.Text.ToUpper() + "','" + txtMandal.Text.ToUpper() + "','" + txtDistrict.Text.ToUpper() + "','" + txtState.Text.ToUpper() + "','" + txtPin.Text.ToUpper() + "','" + sStatus + "','" + txtOwnerName.Text.ToUpper() + "','" + txtMobileNo.Text.ToUpper() + "','" + txtBankAccNo.Text.ToUpper() + "'," + Convert.ToInt32(txtSDAmt.Text) + "," + Convert.ToInt32(txtMonthlyRent.Text) + ",'" + CommonData.LogUserId + "','" + Convert.ToDateTime(CommonData.CurrentDate).ToString("dd/MMM/yyyy") + "','" + txtRemarks.Text.ToString().Replace("'", "") + "'," + txtArea.Text.ToString() + "," + txtBags.Text.ToString() + ") "; } else { sqlText += " UPDATE SP_RENTAL_AGRIMENTS_DETL SET SPRAD_TRN_TYPE='" + cmbTrnType.Text.ToUpper() + "'" + ",SPRAD_FROM='" + Convert.ToDateTime(dtpFromDate.Value).ToString("dd/MMM/yyyy") + "'" + ",SPRAD_TO='" + Convert.ToDateTime(dtpToDate.Value).ToString("dd/MMM/yyyy") + "'" + ",SPRAD_GODOWN_ADDRESS='" + txtBranchAdd.Text.ToUpper() + "'" + ",SPRAD_GODOWN_LOCATION='" + txtLocation.Text.ToUpper() + "'" + ",SPRAD_GODOWN_MONDAL='" + txtMandal.Text.ToUpper() + "'" + ",SPRAD_GODOWN_DISTRICT='" + txtDistrict.Text.ToUpper() + "'" + ",SPRAD_GODOWN_STATE='" + txtState.Text.ToUpper() + "'" + ",SPRAD_GODOWN_PIN='" + txtPin.Text.ToUpper() + "'" + ",SPRAD_OWNER_NAME='" + txtOwnerName.Text.ToUpper() + "'" + ",SPRAD_MOBILE_NO='" + txtMobileNo.Text.ToUpper() + "'" + ",SPRAD_BANK_ACC_NO='" + txtBankAccNo.Text.ToUpper() + "'" + ",SPRAD_AGGRIMENT_STATUS='" + sStatus + "'" + ",SPRAD_SD_AMT=" + txtSDAmt.Text.ToUpper() + ",SPRAD_MTLY_RNT_AMT=" + txtMonthlyRent.Text.ToUpper() + ",SPRAD_REMARKS='" + txtRemarks.Text.ToString().Replace("'", "") + "',SPRAD_AREA_SFT=" + txtArea.Text.ToUpper() + ",SPRAD_CAPACITY_BAGS=" + txtBags.Text.ToUpper() + ",SPRAD_LAST_MODIFIED_BY='" + CommonData.LogUserId + "',SPRAD_LAST_MODIFIED_DATE='" + Convert.ToDateTime(CommonData.CurrentDate).ToString("dd/MMM/yyyy") + "' WHERE SPRAD_BRANCH_CODE='" + sBrDetl[1] + "' AND SPRAD_TRN_NO=" + txtTrnNo.Text; } if (sqlText.Length > 5) { iRes = objDB.ExecuteSaveData(sqlText); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { objDB = null; } if (iRes == 0) { MessageBox.Show("Data Not Saved", "SP Rental Agriment", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Data Saved Successfully", "SP Rental Agriment", MessageBoxButtons.OK, MessageBoxIcon.Information); btnClear_Click(null, null); } } }
private void FillRentalAgrimentDataToGrid() { objSPDB = new StockPointDB(); DataTable dtSpRntDetl = new DataTable(); string[] sBrDetl = null; sBrDetl = cmbBranch.SelectedValue.ToString().Split('@'); dtSpRntDetl = objSPDB.SPRentalAgrimentDetl_Get(sBrDetl[0], sBrDetl[1], 0).Tables[0]; gvLicence.Rows.Clear(); if (dtSpRntDetl.Rows.Count > 0) { for (int i = 0; i < dtSpRntDetl.Rows.Count; i++) { DataGridViewRow tempRow = new DataGridViewRow(); DataGridViewCell cellSlNo = new DataGridViewTextBoxCell(); cellSlNo.Value = i + 1; tempRow.Cells.Add(cellSlNo); DataGridViewCell cellBrCode = new DataGridViewTextBoxCell(); cellBrCode.Value = dtSpRntDetl.Rows[i]["SPRAD_BRANCH_CODE"]; tempRow.Cells.Add(cellBrCode); DataGridViewCell cellTrnNo = new DataGridViewTextBoxCell(); cellTrnNo.Value = dtSpRntDetl.Rows[i]["SPRAD_TRN_NO"]; tempRow.Cells.Add(cellTrnNo); DataGridViewCell cellTrnType = new DataGridViewTextBoxCell(); cellTrnType.Value = dtSpRntDetl.Rows[i]["SPRAD_TRN_TYPE"]; tempRow.Cells.Add(cellTrnType); DataGridViewCell cellVFrom = new DataGridViewTextBoxCell(); cellVFrom.Value = Convert.ToDateTime(dtSpRntDetl.Rows[i]["SPRAD_FROM"]).ToString("dd-MMM-yyyy").ToUpper(); tempRow.Cells.Add(cellVFrom); DataGridViewCell cellVTo = new DataGridViewTextBoxCell(); cellVTo.Value = Convert.ToDateTime(dtSpRntDetl.Rows[i]["SPRAD_TO"]).ToString("dd-MMM-yyyy").ToUpper(); tempRow.Cells.Add(cellVTo); DataGridViewCell cellAddrs = new DataGridViewTextBoxCell(); cellAddrs.Value = dtSpRntDetl.Rows[i]["SPRAD_GODOWN_ADDRESS"]; tempRow.Cells.Add(cellAddrs); DataGridViewCell cellLoc = new DataGridViewTextBoxCell(); cellLoc.Value = dtSpRntDetl.Rows[i]["SPRAD_GODOWN_LOCATION"]; tempRow.Cells.Add(cellLoc); DataGridViewCell cellDistr = new DataGridViewTextBoxCell(); cellDistr.Value = dtSpRntDetl.Rows[i]["SPRAD_GODOWN_DISTRICT"]; tempRow.Cells.Add(cellDistr); DataGridViewCell cellMand = new DataGridViewTextBoxCell(); cellMand.Value = dtSpRntDetl.Rows[i]["SPRAD_GODOWN_MONDAL"]; tempRow.Cells.Add(cellMand); DataGridViewCell cellState = new DataGridViewTextBoxCell(); cellState.Value = dtSpRntDetl.Rows[i]["SPRAD_GODOWN_STATE"]; tempRow.Cells.Add(cellState); DataGridViewCell cellPin = new DataGridViewTextBoxCell(); cellPin.Value = dtSpRntDetl.Rows[i]["SPRAD_GODOWN_PIN"]; tempRow.Cells.Add(cellPin); DataGridViewCell cellOwner = new DataGridViewTextBoxCell(); cellOwner.Value = dtSpRntDetl.Rows[i]["SPRAD_OWNER_NAME"]; tempRow.Cells.Add(cellOwner); DataGridViewCell cellSDAmt = new DataGridViewTextBoxCell(); cellSDAmt.Value = dtSpRntDetl.Rows[i]["SPRAD_SD_AMT"]; tempRow.Cells.Add(cellSDAmt); DataGridViewCell cellMnthlyAmt = new DataGridViewTextBoxCell(); cellMnthlyAmt.Value = dtSpRntDetl.Rows[i]["SPRAD_MTLY_RNT_AMT"]; tempRow.Cells.Add(cellMnthlyAmt); DataGridViewCell cellStatus = new DataGridViewTextBoxCell(); cellStatus.Value = dtSpRntDetl.Rows[i]["SPRAD_AGGRIMENT_STATUS"]; tempRow.Cells.Add(cellStatus); DataGridViewCell cellRemarks = new DataGridViewTextBoxCell(); cellRemarks.Value = dtSpRntDetl.Rows[i]["SPRAD_REMARKS"]; tempRow.Cells.Add(cellRemarks); DataGridViewCell cellArea = new DataGridViewTextBoxCell(); cellArea.Value = dtSpRntDetl.Rows[i]["SPRAD_AREA_SFT"]; tempRow.Cells.Add(cellArea); DataGridViewCell cellBags = new DataGridViewTextBoxCell(); cellBags.Value = dtSpRntDetl.Rows[i]["SPRAD_CAPACITY_BAGS"]; tempRow.Cells.Add(cellBags); DataGridViewCell cellMobileNo = new DataGridViewTextBoxCell(); cellMobileNo.Value = dtSpRntDetl.Rows[i]["SPRAD_MOBILE_NO"]; tempRow.Cells.Add(cellMobileNo); DataGridViewCell cellBankAccNo = new DataGridViewTextBoxCell(); cellBankAccNo.Value = dtSpRntDetl.Rows[i]["SPRAD_BANK_ACC_NO"]; tempRow.Cells.Add(cellBankAccNo); gvLicence.Rows.Add(tempRow); } } objSPDB = null; dtSpRntDetl = null; }
private void FillBranches() { tvBranches.Nodes.Clear(); objSPdb = new StockPointDB(); DataSet ds = new DataSet(); try { ds = objSPdb.Get_UserBranchesWithStateFilter("", "", CommonData.LogUserId, "", "PARENT"); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { tvBranches.Nodes.Add(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), ds.Tables[0].Rows[i]["COMPANY_NAME"].ToString()); DataSet dsState = new DataSet(); dsState = objSPdb.Get_UserBranchesWithStateFilter(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), "", CommonData.LogUserId, "", "STATE"); if (dsState.Tables[0].Rows.Count > 0) { for (int j = 0; j < dsState.Tables[0].Rows.Count; j++) { tvBranches.Nodes[i].Nodes.Add(dsState.Tables[0].Rows[j]["StateCode"].ToString(), dsState.Tables[0].Rows[j]["StateName"].ToString()); DataSet dschild = new DataSet(); // Filling Branches if (sFrmType == "TOUR_EXPENSES") { dschild = objSPdb.Get_UserBranchesWithStateFilter(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), dsState.Tables[0].Rows[j]["StateCode"].ToString(), CommonData.LogUserId, "BR", "CHILD"); tvBranches.Nodes[i].Nodes[j].Nodes.Add("BRANCHES" + "(" + dschild.Tables[0].Rows.Count + ")"); if (dschild.Tables[0].Rows.Count > 0) { for (int k = 0; k < dschild.Tables[0].Rows.Count; k++) { tvBranches.Nodes[i].Nodes[j].Nodes[0].Nodes.Add(dschild.Tables[0].Rows[k]["BranchCode"].ToString(), dschild.Tables[0].Rows[k]["BranchName"].ToString()); } } dschild = objSPdb.Get_UserBranchesWithStateFilter(ds.Tables[0].Rows[i]["COMPANY_CODE"].ToString(), dsState.Tables[0].Rows[j]["StateCode"].ToString(), CommonData.LogUserId, "HO", "CHILD"); tvBranches.Nodes[i].Nodes[j].Nodes.Add("HO" + "(" + dschild.Tables[0].Rows.Count + ")"); if (dschild.Tables[0].Rows.Count > 0) { for (int k = 0; k < dschild.Tables[0].Rows.Count; k++) { tvBranches.Nodes[i].Nodes[j].Nodes[1].Nodes.Add(dschild.Tables[0].Rows[k]["BranchCode"].ToString(), dschild.Tables[0].Rows[k]["BranchName"].ToString()); } } } } } } } if (ds.Tables[0].Rows.Count > 0) { this.tvBranches.SelectedNode = tvBranches.Nodes[0]; this.tvBranches.SelectedNode.Expand(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }