public void MDConvertPointType(string pointid) { try { string instname = PublicClass.currentInstrument; DataTable dtpoint = DbClass.getdata(CommandType.Text, "select max(ID)typepoint_id from Type_point"); foreach (DataRow drsen in dtpoint.Rows) { untypeid = Convert.ToString(PublicClass.DefVal(Convert.ToString(drsen["typepoint_id"]), "0")) + 1; string AlarmID = "0"; string sdID = "0"; string perID = "0"; string PointTypeName = Convert.ToString(sSplittedValue[sSplittedValue.Length - 2] + "-" + untypeid); DbClass.executequery(CommandType.Text, "Insert into type_point(Point_Name,Type_ID,Instrumentname,Alarm_ID,STDDeviationAlarm_ID,Percentage_AlarmID,Band_ID) values('" + PointTypeName + "','1','" + instname + "','" + AlarmID + "','" + sdID + "','" + perID + "','0')"); DataTable dt1 = DbClass.getdata(CommandType.Text, "select distinct ID from type_point where Point_name='" + PointTypeName + "'"); foreach (DataRow dr1 in dt1.Rows) { untypeid = (Convert.ToString(dr1["ID"])); } } try { DbClass.executequery(CommandType.Text, "insert Into c911_measurement(type_id,Channel1,SelectRadio1,EV_Frequency,Channel2,SelectRadio2,Spectrum_LineNo,Window_Type,Fmin,Fmax,Trigger_Mode,Avg_Mode,N,Comments) values('" + untypeid + "','" + ChnlA + "','" + Measurement + "','" + Ampenvcr + "', '" + ChnlB + "','" + Measurement2 + "', '" + Number_Of_Spectrum + "','" + Window + "','" + dF + "','" + HighestFrequency + "','" + Trig + "','" + Avgm + "','" + Navg + "','')"); DbClass.executequery(CommandType.Text, "update point set pointtype_id='" + untypeid + "' where point_id='" + NewID + "'"); } catch { } } catch { } }
public void InsertRouteName() { try { if (CmbLevel.SelectedIndex == 0) { MessageBox.Show(this, "Please select the Level", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } RouteConn.executequery(CommandType.Text, "insert route_data (Route_Name ,Route_Level,Date,DatabaseName) values ( '" + Convert.ToString(TxtRouteName.Text) + "','" + Convert.ToString(CmbLevel.Text) + "' ,'" + PublicClass.GetDatetime() + "' ,'" + PublicClass.User_DataBase + "' ) "); DataTable dt = new DataTable(); dt = RouteConn.getdata(CommandType.Text, "select max(Id) from route_data"); string SId = PublicClass.DefVal(Convert.ToString(dt.Rows[0][0]), "0"); Node_Parent = null; TxtRouteID.Text = Convert.ToString(Convert.ToInt32(SId)); TxtRouteName.Text = "Route" + TxtRouteID.Text; TxtRouteName.Properties.ReadOnly = false; Node_Parent = trlRoute11.AppendNode(new object[] { Convert.ToString(TxtRouteID.Text).Trim(), Convert.ToString(TxtRouteName.Text).Trim(), "Route" }, Node_Parent); trlRoute11.SetFocusedNode(Node_Parent); TxtRouteName.Focus(); _objMain.lblStatus.Caption = "Status: Creating Route"; } catch { } }
private void dgvBADA_Leave(object sender, EventArgs e) { try { if (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(V_Band_Group_id).Trim(), "0")) == 0) { MessageBox.Show("Please Select the Group Name or Create a New Group ", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvBADA.Rows.Clear(); return; } DataTable dt = new DataTable(); dt = DbClass.getdata(CommandType.StoredProcedure, " call Get_DemoDAtaByID ( '" + V_Band_Group_id + "')"); for (int a = 0; a < dgvBADA.Rows.Count - 1; a++) { BAName = Convert.ToString(dgvBADA.Rows[a].Cells["colBANameDemo"].Value).Trim(); BAValue = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBADA.Rows[a].Cells["colFrqDemo"].Value)).Trim(), "0")); xAxis = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBADA.Rows[a].Cells["dgvXDemo"].Value)).Trim(), "0")); yAxis = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBADA.Rows[a].Cells["dgvYDemo"].Value)).Trim(), "0")); string pba_id = Convert.ToString(a + 1); if (BAName == " " || BAValue == 0 || xAxis == 0 || yAxis == 0) { MessageBox.Show("Please fill all the values properly"); return; } if (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dgvBADA.Rows[a].Cells["idDemo"].Value).Trim(), "0")) == 0 && Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dgvBADA.Rows[a].Cells["colCounterDemo"].Value).Trim(), "0")) == 0) { for (int axisId = 4; axisId <= 7; axisId++) { D_Axis_type_v = axisId; DbClass.executequery(CommandType.StoredProcedure, "call Insert_DemodulateBand('" + BAName.Trim() + "' , '" + BAValue + "' ,'" + xAxis + "' ,'" + yAxis + "' ,'" + pba_id + "' , '" + PublicClass.GetDatetime() + "','" + V_Band_Group_id + "','" + D_Axis_type_v + "')"); } DataTable DT = new DataTable(); DT = DbClass.getdata(CommandType.StoredProcedure, " call Get_MaxIdOfDemoBand "); dgvBADA.Rows[a].Cells["idDemo"].Value = Convert.ToString(Convert.ToInt32(PublicClass.DefVal(Convert.ToString(DT.Rows[0][0]), "0"))); dgvBADA.Rows[a].Cells["colCounterDemo"].Value = pba_id; } else { if ((BAName != Convert.ToString(dt.Rows[0]["Demodulate_Name"]).Trim()) || ((BAValue != Convert.ToDouble(Convert.ToString(dt.Rows[0]["Freq"]).Trim())) || (xAxis != Convert.ToDouble(Convert.ToString(dt.Rows[0]["X"]).Trim())) || (yAxis != Convert.ToDouble(Convert.ToString(dt.Rows[0]["Y"]).Trim())))) { DbClass.executequery(CommandType.StoredProcedure, "call Update_DemoData ('" + BAName + "' , '" + BAValue + "' , '" + xAxis + "' , '" + yAxis + "' , '" + PublicClass.GetDatetime() + "','" + PublicClass.DefVal(Convert.ToString(dgvBADA.Rows[a].Cells["colCounterDemo"].Value), "0") + "','" + V_Band_Group_id + "')"); } } } } catch { } }
private void btnDelete_Click(object sender, EventArgs e) { try { int ee = DgvNotes.CurrentRow.Index; string bidd = PublicClass.DefVal(Convert.ToString(DgvNotes.CurrentRow.Cells["colID"].Value).Trim(), "0"); DbClass.executequery(CommandType.StoredProcedure, "call Delete_Notes('" + bidd + "')"); DgvNotes.Rows.RemoveAt(ee); _objMain.lblStatus.Caption = "Status: Deleting Existing Notes"; } catch { } }
private void dgvBAPH_Leave(object sender, EventArgs e) { try { if (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(V_Band_Group_id).Trim(), "0")) == 0) { MessageBox.Show("Please Select the Group Name or Create a New Group ", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvBAPH.Rows.Clear(); return; } DataTable dt = new DataTable(); dt = DbClass.getdata(CommandType.StoredProcedure, " call BandData_By_ID ('" + V_Band_Group_id + "')"); for (int a = 0; a < dgvBAPH.Rows.Count - 1; a++) { BAName = Convert.ToString(dgvBAPH.Rows[a].Cells["colBANamePWR"].Value).Trim(); BAValue = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBAPH.Rows[a].Cells["colFrqPwr"].Value)).Trim(), "0")); xAxis = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBAPH.Rows[a].Cells["colxAxisPwr"].Value)).Trim(), "0")); yAxis = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBAPH.Rows[a].Cells["colYaxisPwr"].Value)).Trim(), "0")); if (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dgvBAPH.Rows[a].Cells["ID"].Value).Trim(), "0")) == 0 && Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dgvBAPH.Rows[a].Cells["colCounterPWR"].Value).Trim(), "0")) == 0) { string pba_id = Convert.ToString(a + 1); for (int axisId = 0; axisId <= 3; axisId++) { B_Axis_type_v = axisId; DbClass.executequery(CommandType.StoredProcedure, "call Insert_PowerBand('" + BAName.Trim() + "' , '" + BAValue + "' ,'" + xAxis + "' ,'" + yAxis + "' ,'" + pba_id + "' , '" + PublicClass.GetDatetime() + "','" + V_Band_Group_id.Trim() + "','" + B_Axis_type_v + "')"); } DataTable DT = new DataTable(); DT = DbClass.getdata(CommandType.StoredProcedure, "call Get_MaxIDOfBandData "); dgvBAPH.Rows[a].Cells["ID"].Value = Convert.ToString(Convert.ToInt32(PublicClass.DefVal(Convert.ToString(DT.Rows[0][0]), "0"))); dgvBAPH.Rows[a].Cells["colCounterPWR"].Value = pba_id; } else { if ((BAName != Convert.ToString(dt.Rows[0]["BandAlarm_Name"]).Trim()) || ((BAValue != Convert.ToDouble(Convert.ToString(dt.Rows[0]["Freq"]).Trim())))) { DbClass.executequery(CommandType.StoredProcedure, "call Update_BandData( '" + BAName + "' , '" + BAValue + "' , '" + xAxis + "' , '" + yAxis + "' , '" + PublicClass.GetDatetime() + "' , '" + PublicClass.DefVal(Convert.ToString(dgvBAPH.Rows[a].Cells["colCounterPWR"].Value), "0") + "' ,'" + V_Band_Group_id.Trim() + "' )"); } } } } catch { } }
private void DgvNotes_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Delete) { int ee = DgvNotes.CurrentRow.Index; string bidd = PublicClass.DefVal(Convert.ToString(DgvNotes.CurrentRow.Cells["colID"].Value).Trim(), "0"); DbClass.executequery(CommandType.StoredProcedure, "call Delete_Notes('" + bidd + "')"); DgvNotes.Rows.RemoveAt(ee); } } catch { } }
private void dgvFaultFreq_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Delete) { int ee = dgvBAPH.CurrentRow.Index; string bidd = PublicClass.DefVal(Convert.ToString(dgvBAPH.CurrentRow.Cells["ID"].Value).Trim(), "0"); DbClass.executequery(CommandType.StoredProcedure, "call Delete_BandDataByID('" + bidd + "')"); dgvBAPH.Rows.RemoveAt(ee); } } catch { } }
private void dgvBADA_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Delete) { int ee = dgvBADA.CurrentRow.Index; string didd = PublicClass.DefVal(Convert.ToString(dgvBADA.CurrentRow.Cells["colCounterDemo"].Value).Trim(), "0"); DbClass.executequery(CommandType.StoredProcedure, "call Delete_DemoDataByID('" + PublicClass.DefVal(Convert.ToString(dgvBADA.CurrentRow.Cells["colCounterDemo"].Value).Trim(), "0") + "','" + V_Band_Group_id + "')"); dgvBADA.Rows.RemoveAt(ee); } } catch { } }
private void tsbtnSave_Click(object sender, EventArgs e) { try { for (int a = 0; a < DgvNotes.Rows.Count; a++) { notesDesc = Convert.ToString(DgvNotes.Rows[a].Cells["colNotes"].Value).Trim(); nid = Convert.ToInt32(PublicClass.DefVal(Convert.ToString(DgvNotes.Rows[a].Cells["colID"].Value).Trim(), "0")); //int nIndex = DgvNotes.CurrentRow.Index; if (notesDesc == "") { return; } DataTable cdt = new DataTable(); cdt = DbClass.getdata(CommandType.StoredProcedure, " call Get_cNotes('" + nid + "') "); foreach (DataRow dr in cdt.Rows) { dNotes = Convert.ToString(dr["Notes_Desc"]); dId = Convert.ToInt32(dr["Note_type"]); } if (cdt.Rows.Count - 1 < 0) { DbClass.executequery(CommandType.StoredProcedure, "call Insert_Notes('" + notesDesc + "' , '" + SETLevel(Convert.ToString(DgvNotes.Rows[a].Cells["colLevel"].Value).Trim()) + "' , '" + PublicClass.GetDatetime() + "' )"); } else { if (dNotes != notesDesc || dId != nid) { DbClass.executequery(CommandType.StoredProcedure, "call Update_Notes('" + notesDesc + "' , '" + PublicClass.GetDatetime() + "' , '" + SETLevel(Convert.ToString(DgvNotes.Rows[a].Cells["colLevel"].Value).Trim()) + "' , ' " + nid + "' )"); } } } if (DgvNotes.Rows.Count > 0) { MessageBox.Show("Data Saved Successfully"); _objMain.lblStatus.Caption = "Status: Notes Saved Successfully"; this.Close(); } } catch { } }
public int getLegend(string Query) { int i = 0; try { DataTable dtt = new DataTable(); dtt = DbClass.getdata(CommandType.Text, "select distinct alarm_id from v_AllRecord where " + Query + " and Alarm_ID <> '' "); string ids = "pd." + Query; foreach (DataRow dr in dtt.Rows) { i = objUserControl.checkValueForFlagGenerate(ids, PublicClass.DefVal(Convert.ToString(dr["alarm_id"]), "0"), i); } } catch { } return(i); }
public string GetBandGroupID(string Bandgroupname) { try { DataTable dtBandAramGroup = new DataTable(); dtBandAramGroup = DbClass.getdata(CommandType.Text, "select distinct Bandalarmsgroup_id from bandalarm_data where bandalarmsgroup_Name = '" + Bandgroupname.Trim() + "' "); if (dtBandAramGroup.Rows.Count > 0) { V_Band_Group_id = PublicClass.DefVal(Convert.ToString(dtBandAramGroup.Rows[0][0]), "0"); } else { V_Band_Group_id = "0"; } } catch { } return(V_Band_Group_id); }
public void Fill_TrlRoute_MachineWise() { try { DataTable dt = new DataTable(); dt = RouteConn.getdata(CommandType.Text, "select distinct a.Id,a.Route_Name,a.Route_Level,b.Type_ID from route_data a left join route_data1 b on a.id=b.ID where Route_Level='" + CmbLevel.Text.Trim().ToString() + "' and databasename='" + PublicClass.User_DataBase + "' "); DataTable dtt = new DataTable(); dtt = RouteConn.getdata(CommandType.Text, "select distinct a.Id ,a.Route_Name from route_data a left join route_data1 b on a.id=b.ID where Route_Level='" + CmbLevel.Text.Trim().ToString() + "' and databasename='" + PublicClass.User_DataBase + "' "); foreach (DataRow drr in dtt.Rows) { TreeListNode node = null; node = trlRoute11.AppendNode(new object[] { Convert.ToString(drr["Id"]), Convert.ToString(drr["Route_Name"]), "Route" }, node); trlRoute11.SetFocusedNode(node); foreach (DataRow dr in dt.Select("Id ='" + Convert.ToString(drr["Id"]).Trim() + "' ")) { Insert_Machine(PublicClass.DefVal(Convert.ToString(dr["Type_ID"]), "0")); } } } catch { } }
private bool chkValue() { bool status = false; try { string hAxial = Convert.ToString(PublicClass.DefVal(txtHAxial.Text, "0")); string lAxial = Convert.ToString(PublicClass.DefVal(txtLAxial.Text, "0")); string hHorizontal = Convert.ToString(PublicClass.DefVal(txtHHorizontal.Text, "0")); string lHorizontal = Convert.ToString(PublicClass.DefVal(txtLHorizontal.Text, "0")); string hVertical = Convert.ToString(PublicClass.DefVal(txtHVertical.Text, "0")); string lVertical = Convert.ToString(PublicClass.DefVal(txtLVertical.Text, "0")); string hCh1 = Convert.ToString(PublicClass.DefVal(txtHCh1.Text, "0")); string lCh1 = Convert.ToString(PublicClass.DefVal(txtLCh1.Text, "0")); if (hAxial == "0" && hHorizontal == "0" && hVertical == "0" && hCh1 == "0")//&& hHorizontal == "" && lHorizontal == "" && hVertical == "" && lVertical == "" && hCh1 == "" && lCh1 == "") { MessageBox.Show(this, "Fill atleast one direction value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(status = false); } if (lAxial == "0" && lHorizontal == "0" && lVertical == "0" && lCh1 == "0")//&& hHorizontal == "" && lHorizontal == "" && hVertical == "" && lVertical == "" && hCh1 == "" && lCh1 == "") { MessageBox.Show(this, "Fill atleast one direction value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(status = false); } if (((hAxial != "0" && lAxial == "0") || (hAxial == "0" && lAxial != "0"))) { MessageBox.Show(this, "Fill both axis values", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(status = false); } else if ((hHorizontal != "0" && lHorizontal == "0") || (hHorizontal == "0" && lHorizontal != "0")) { MessageBox.Show(this, "Fill both axis values", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(status = false); } else if ((hVertical != "0" && lVertical == "0") || (hVertical == "0" && lVertical != "0")) { MessageBox.Show(this, "Fill both axis values", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(status = false); } else if ((hCh1 != "0" && lCh1 == "0") || (hCh1 == "0" && lCh1 != "0")) { MessageBox.Show(this, "Fill both axis values", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(status = false); } else { } try { if ((Convert.ToInt32(hAxial) < Convert.ToInt32(lAxial)) || (Convert.ToInt32(hHorizontal) < Convert.ToInt32(lHorizontal)) || (Convert.ToInt32(hVertical) < Convert.ToInt32(lVertical)) || ((Convert.ToInt32(hAxial) < Convert.ToInt32(lAxial)))) { MessageBox.Show(this, "High value must be greater than low value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtHCh1.Text = ""; txtHVertical.Text = ""; txtLVertical.Text = ""; txtHHorizontal.Text = ""; txtHAxial.Text = ""; txtLAxial.Text = ""; txtLHorizontal.Text = ""; txtLCh1.Text = ""; status = false; } else { if (((Convert.ToInt32(hAxial) == val) || (Convert.ToInt32(hAxial) < val)) && ((Convert.ToInt32(hHorizontal) == val) || (Convert.ToInt32(hHorizontal) < val)) && ((Convert.ToInt32(hVertical) == val) || (Convert.ToInt32(hVertical) < val)) && ((Convert.ToInt32(hCh1) == val) || (Convert.ToInt32(hCh1) < val))) { if (txtHAxial.Enabled == true) { try { if ((Convert.ToInt32(hAxial) >= Convert.ToInt32(lAxial))) { status = true; } } catch { } } if (txtHHorizontal.Enabled == true) { try { if ((Convert.ToInt32(hHorizontal) >= Convert.ToInt32(lHorizontal))) { status = true; } } catch { } } if (txtHVertical.Enabled == true) { try { if ((Convert.ToInt32(hVertical) >= Convert.ToInt32(lVertical))) { status = true; } } catch { } } if (txtHCh1.Enabled == true) { try { if ((Convert.ToInt32(hAxial) >= Convert.ToInt32(lAxial))) { status = true; } } catch { } } // status = true; } else { MessageBox.Show(this, "High value must be equals to or less than='" + val + "' ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtHCh1.Text = ""; txtHVertical.Text = ""; txtLVertical.Text = ""; txtHHorizontal.Text = ""; txtHAxial.Text = ""; txtLAxial.Text = ""; txtLHorizontal.Text = ""; txtLCh1.Text = ""; status = false; } } } catch { } return(status); } catch { } return(status); }
public void InsertItemsInDataBase(string sNodeType, string sParentID, string sDescription) { try { if (sNodeType != "" && sParentID != "" && sDescription != "") { string[] sSplittedValue = sDescription.Split(new char[] { '|' }); string sFactoryName = sSplittedValue[0]; string sFactoryDescription = sSplittedValue[1]; if (sNodeType == "Plant") { try { string facName = sFactoryName; int hyPreviousID = 0; int hyNextId = 0; DbClass.executequery(CommandType.Text, "Insert into factory_info(Name,Description,DateCreated,PreviousID,NextID) values('" + facName + "','Plant','" + PublicClass.GetDatetime() + "','" + hyPreviousID + "','" + hyNextId + "')"); DataTable dtfacfinal = DbClass.getdata(CommandType.Text, "Select max(factory_id) from factory_info "); hyPreviousID = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtfacfinal.Rows[0][0]), "0"))) - 1; hyNextId = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtfacfinal.Rows[0][0]), "0"))) + 1; DbClass.executequery(CommandType.Text, "Update factory_info set PreviousID = '" + hyPreviousID + "',NextID='" + hyNextId + "' where factory_id = '" + Convert.ToString(dtfacfinal.Rows[0][0]) + "'"); facid = Convert.ToString(dtfacfinal.Rows[0][0]); } catch { } } else if (sNodeType == "Area") { string AreaName = sFactoryName; string facid1 = facid; int PreviousID = 0; int NextId = 0; DbClass.executequery(CommandType.Text, "Insert into area_info(Name,Description,FactoryID,PreviousID,NextID,DateCreated) values('" + AreaName + "','Area','" + facid1 + "','" + PreviousID + "','" + NextId + "','" + PublicClass.GetDatetime() + "')"); DataTable dtareafinal = DbClass.getdata(CommandType.Text, "Select max(Area_ID) from area_info "); PreviousID = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtareafinal.Rows[0][0]), "0"))) - 1; NextId = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtareafinal.Rows[0][0]), "0"))) + 1; DbClass.executequery(CommandType.Text, "Update area_info set PreviousID = '" + PreviousID + "',NextID='" + NextId + "' where Area_ID = '" + Convert.ToString(dtareafinal.Rows[0][0]) + "'"); facid = Convert.ToString(dtareafinal.Rows[0][0]); } else if (sNodeType == "Train") { string AreaName = sFactoryName; string facid2 = facid; int PreviousID = 0; int NextId = 0; DbClass.executequery(CommandType.Text, "Insert into train_info(Name,Description,PreviousID,NextID,Area_ID,Date) values('" + AreaName + "','Train','" + PreviousID + "','" + NextId + "','" + facid2 + "','" + PublicClass.GetDatetime() + "')"); DataTable dtTrainfinal = DbClass.getdata(CommandType.Text, "Select max(Train_ID) from train_info "); PreviousID = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtTrainfinal.Rows[0][0]), "0"))) - 1; NextId = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtTrainfinal.Rows[0][0]), "0"))) + 1; DbClass.executequery(CommandType.Text, "Update train_info set PreviousID = '" + PreviousID + "',NextID='" + NextId + "' where Train_ID = '" + Convert.ToString(dtTrainfinal.Rows[0][0]) + "'"); facid = Convert.ToString(dtTrainfinal.Rows[0][0]); } else if (sNodeType == "Machine") { string AreaName = sFactoryName; string facid3 = facid; int PreviousID = 0; int NextId = 0; DbClass.executequery(CommandType.Text, "Insert into machine_info(Name,Description,PreviousID,NextID,TrainID,DateCreated,RPM_Driven,PulseRev) values('" + sFactoryName + "','Machine','" + PreviousID + "','" + NextId + "','" + facid3 + "','" + PublicClass.GetDatetime() + "','1800','1')"); DataTable dtmacfinal = DbClass.getdata(CommandType.Text, "Select max(Machine_ID) from machine_info "); PreviousID = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtmacfinal.Rows[0][0]), "0"))) - 1; NextId = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtmacfinal.Rows[0][0]), "0"))) + 1; DbClass.executequery(CommandType.Text, "Update machine_info set PreviousID = '" + PreviousID + "',NextID='" + NextId + "' where Machine_ID = '" + Convert.ToString(dtmacfinal.Rows[0][0]) + "'"); // facid = Convert.ToString(dtmacfinal.Rows[0][0]); } else if (sNodeType == "Point") { string prID = facid; int PreviousID = 0; int NextId = 0; DbClass.executequery(CommandType.Text, "Insert into point(PointName,PointDesc,DataCreated,PreviousID,NextID,Machine_ID,DataSchedule,PointStatus,PointSchedule) values('" + sFactoryName + "','Point','" + PublicClass.GetDatetime() + "','" + PreviousID + "','" + NextId + "','" + prID + "','7','0','1')"); DataTable dtpointfinal = DbClass.getdata(CommandType.Text, "Select max(Point_ID) from point "); PreviousID = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtpointfinal.Rows[0][0]), "0"))) - 1; NextId = (Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dtpointfinal.Rows[0][0]), "0"))) + 1; DbClass.executequery(CommandType.Text, "Update point set PreviousID = '" + PreviousID + "',NextID='" + NextId + "',PointType_ID='0' where Point_ID = '" + Convert.ToString(dtpointfinal.Rows[0][0]) + "'"); NewID = Convert.ToString(dtpointfinal.Rows[0][0]); } } } catch { } }
public void filldgvNotes() { try { DataTable dt = new DataTable(); dt = DbClass.getdata(CommandType.Text, "call Get_Notes"); int i = 0; DgvNotes.Rows.Clear(); foreach (DataRow dr in dt.Rows) { //Notes_Desc , Note_type , Date,notes_id DgvNotes.Rows.Add(); DgvNotes.Rows[i].Cells["colID"].Value = Convert.ToString(dr["notes_id"]); DgvNotes.Rows[i].Cells["colDate"].Value = Convert.ToString(dr["Date"]); DgvNotes.Rows[i].Cells["colNotes"].Value = Convert.ToString(dr["Notes_Desc"]); DgvNotes.Rows[i].Cells["colLevel"].Value = SETLevel(Convert.ToInt32(PublicClass.DefVal(Convert.ToString(dr["Note_type"]).Trim(), "0"))); i = i + 1; } } catch { } }
private void dgvBADA_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { string cColumn = null; cColumn = dgvBADA.Columns[e.ColumnIndex].HeaderText; xAxis = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBADA.CurrentRow.Cells["dgvXDemo"].Value)), "0")); yAxis = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBADA.CurrentRow.Cells["dgvYDemo"].Value)), "0")); switch (cColumn) { case "Band Name": { BAName = Convert.ToString(dgvBADA.CurrentRow.Cells["colBANameDemo"].Value).Trim(); if (BAName == " ") { MessageBox.Show("Name Can't be Blank"); } break; } case "Frequency": { BAValue = Convert.ToDouble(PublicClass.DefVal(Convert.ToString((dgvBADA.CurrentRow.Cells["colFrqDemo"].Value)), "0")); int fvalueIndex = dgvBADA.CurrentRow.Index; if (fvalueIndex == 0) { double nRowValue = Convert.ToDouble(PublicClass.DefVal(Convert.ToString(dgvBADA.Rows[fvalueIndex + 1].Cells["colFrqDemo"].Value), "0")); if (nRowValue != 0) { if (nRowValue <= BAValue) { MessageBox.Show("Frequency value can not be greater than from existing Band Alarm"); dgvBADA.CurrentRow.Cells["colFrqDemo"].Value = " "; } } } if (dgvBADA.CurrentRow.Index != 0) { int BAval = dgvBADA.CurrentRow.Index - 1; fCount = Convert.ToDouble(dgvBADA.Rows[BAval].Cells["colFrqDemo"].Value); if (fCount >= BAValue) { MessageBox.Show("Frequency value can not be Less than from existing Band Alarm"); dgvBADA.CurrentRow.Cells["colFrqDemo"].Value = " "; dgvBADA.CurrentCell.Selected = true; } } break; } case "High": { if (xAxis <= yAxis) { MessageBox.Show("High can't less than high"); dgvBADA.CurrentRow.Cells["dgvXDemo"].Value = " "; } break; } case "Low": { if (yAxis >= xAxis) { MessageBox.Show("Low can't greater than high"); dgvBADA.CurrentRow.Cells["dgvYDemo"].Value = " "; } break; } } } catch { } }