private void btnSelect_Click(object sender, EventArgs e) { MTYPE_OF_FORM = cmbTNCSub.Text; if (dgvLOV.CurrentRow != null) { Boolean delflag = false; Boolean insertflag = false; if (DialogResult == System.Windows.Forms.DialogResult.None) { DialogResult = System.Windows.Forms.DialogResult.OK; for (int i = 0; i <= dgvLOV.Rows.Count - 1; i++) { if (dtQTNC.Rows.Count > 0) { for (int j = 0; j < dtQTNC.Rows.Count; j++) { // if(dgvLOV.Rows.Count) if (dgvLOV.Rows[i].Cells[1].Value.ToString().Trim() == dtQTNC.Rows[j][1].ToString().Trim()) { insertflag = false; if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == false) { delflag = true; break; } break; } else { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { string status = ""; for (int x = 0; x < Col1.Count; x++) { if (delEditedFlag == true && i == Convert.ToInt16(Col1[x].ToString())) { status = ""; delflag = true; //insertflag = true; break; } else { status = "Insert"; //insertflag = true; } } if (Col1.Count == 0) { insertflag = true; } else { //if (status == "Insert") if (delEditedFlag == false) { insertflag = true; } } //if (delEditedFlag == false) //{ // insertflag = true; //} //if (delEditedFlag == true && i == EditedRowIndex) //{ // delflag = true; // //insertflag = true; // break; //} //else //{ // insertflag = true; //} //insertflag = true; } } } if (delflag == true) { if (_spName == "usp_QuotationTNC_Select") { string delstatus = ""; for (int x = 0; x < Col1.Count; x++) { if (delEditedFlag == true && i == Convert.ToInt16(Col1[x].ToString())) { objQuotationBL.DeleteTNC(cmbTNCSub.Text, dtOTNC.Rows[Convert.ToInt16(Col1[x].ToString())]["TNC_Desc"].ToString(), _Code); delflag = false; insertflag = true; } else { delstatus = "delete"; } } if (delEditedFlag == false) { objQuotationBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); delflag = false; } //if (delEditedFlag == true && i == EditedRowIndex)//desc modified in edit mode //{ // objQuotationBL.DeleteTNC(cmbTNCSub.Text, dtOTNC.Rows[EditedRowIndex]["TNC_Desc"].ToString(), _Code); // delflag = false; // insertflag = true; //} //else//desc as it is //{ // objQuotationBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); // delflag = false; //} //objQuotationBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); //delflag = false; } else if (_spName == "usp_SalesTNC_Select") { string delstatus = ""; for (int x = 0; x < Col1.Count; x++) { if (delEditedFlag == true && i == Convert.ToInt16(Col1[x].ToString())) { objSalesBL.DeleteTNC(cmbTNCSub.Text, dtOTNC.Rows[Convert.ToInt16(Col1[x].ToString())]["TNC_Desc"].ToString(), _Code); delflag = false; insertflag = true; } else { delstatus = "delete"; } } if (delEditedFlag == false) { objSalesBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); delflag = false; } //objSalesBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); //delflag = false; } else if (_spName == "usp_ServicesTNC_Select") { string delstatus = ""; for (int x = 0; x < Col1.Count; x++) { if (delEditedFlag == true && i == Convert.ToInt16(Col1[x].ToString())) { objServicesBL.DeleteTNC(cmbTNCSub.Text, dtOTNC.Rows[Convert.ToInt16(Col1[x].ToString())]["TNC_Desc"].ToString(), _Code); delflag = false; insertflag = true; } else { delstatus = "delete"; } } if (delEditedFlag == false) { objServicesBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); delflag = false; } //objServicesBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); //delflag = false; } else if (_spName == "usp_PurchaseTNC_Select") { string delstatus = ""; for (int x = 0; x < Col1.Count; x++) { if (delEditedFlag == true && i == Convert.ToInt16(Col1[x].ToString())) { objPurchaseBL.DeleteTNC(cmbTNCSub.Text, dtOTNC.Rows[Convert.ToInt16(Col1[x].ToString())]["TNC_Desc"].ToString(), _Code); delflag = false; insertflag = true; } else { delstatus = "delete"; } } if (delEditedFlag == false) { objServicesBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); delflag = false; } //objServicesBL.DeleteTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); //delflag = false; } } if (insertflag == true) { if (_spName == "usp_QuotationTNC_Select") { objQuotationBL.InsertTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); insertflag = false; } else if (_spName == "usp_SalesTNC_Select") { objSalesBL.InsertTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); insertflag = false; } else if (_spName == "usp_ServicesTNC_Select") { objServicesBL.InsertTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); insertflag = false; } else if (_spName == "usp_PurchaseTNC_Select") { objPurchaseBL.InsertTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); insertflag = false; } } } else { // MessageBox.Show(_Code.Substring(2,2).ToString()); if (_Code.Substring(3, 2) == "QU" || _Code.EndsWith("R%")) // _Code.Substring(18,1)=="R" || { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { objQuotationBL.InsertTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); } } else if (_Code.Substring(0, 2) == "RI" || _Code.Substring(0, 2) == "TI" || _Code.Substring(0, 2) == "ES") { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { objSalesBL.InsertTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); } } else if (_Code.Substring(0, 2) == "SR") { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { objServicesBL.InsertTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); } } else if (_Code.Substring(0, 2) == "PO") { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { objPurchaseBL.InsertTNC(cmbTNCSub.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); } } } } this.Close(); } } }
private void btnSelect_Click(object sender, EventArgs e) { MTYPE_OF_FORM = lblTNC.Text; if (dgvLOV.CurrentRow != null) { Boolean delflag = false; Boolean insertflag = false; if (DialogResult == System.Windows.Forms.DialogResult.None) { DialogResult = System.Windows.Forms.DialogResult.OK; for (int i = 0; i <= dgvLOV.Rows.Count - 1; i++) { if (dtQTNC.Rows.Count > 0) { for (int j = 0; j < dtQTNC.Rows.Count; j++) { if (dgvLOV.Rows[i].Cells[1].Value.ToString() == dtQTNC.Rows[j][1].ToString()) { insertflag = false; if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == false) { delflag = true; break; } break; } else { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { insertflag = true; } } } if (delflag == true) { if (_spName == "usp_QuotationTNC_Select") { objQuotationBL.DeleteTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); delflag = false; } else if (_spName == "usp_SalesTNC_Select") { objSalesBL.DeleteTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); delflag = false; } else if (_spName == "usp_ServicesTNC_Select") { objServicesBL.DeleteTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); delflag = false; } } if (insertflag == true) { if (_spName == "usp_QuotationTNC_Select") { objQuotationBL.InsertTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); insertflag = false; } else if (_spName == "usp_SalesTNC_Select") { objSalesBL.InsertTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); insertflag = false; } else if (_spName == "usp_ServicesTNC_Select") { objServicesBL.InsertTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); insertflag = false; } } } else { if (_Code.Substring(0, 2) == "QU" || _Code.StartsWith("R")) { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { objQuotationBL.InsertTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); } } else if (_Code.Substring(0, 2) == "SI") { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { objSalesBL.InsertTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); } } else if (_Code.Substring(0, 2) == "SR") { if (Convert.ToBoolean(dgvLOV.Rows[i].Cells[0].Value) == true) { objServicesBL.InsertTNC(lblTNC.Text, dgvLOV.Rows[i].Cells[1].Value.ToString(), _Code); } } } } this.Close(); } } }