public void UpdateData(string sType, string argDesc, int argId, int rowno) { string sSql = string.Empty; SqlCommand cmd; int identity; if (sType == "C") { bool bAns = UnitDirBL.FoundCallType(argId, argDesc, sType); if (bAns == true) { MessageBox.Show("Already Exists"); DGvTransView.CancelUpdateCurrentRow(); return; } if (argId == 0) { sSql = String.Format("INSERT INTO CallType(Description) Values('{0}') SELECT SCOPE_IDENTITY();", argDesc); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); identity = Convert.ToInt16(cmd.ExecuteScalar().ToString()); cmd.Dispose(); //DGvTransView.SetRowCellValue(DGvTransView.FocusedRowHandle, "CallTypeId", identity); //DGvTransView.SetRowCellValue(DGvTransView.FocusedRowHandle, "SysDefault", false); sSql = String.Format("Update CallType Set SortID={0} Where CallTypeId= {0}", identity); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); cmd.ExecuteNonQuery(); //CommFun.InsertLog(DateTime.Now, "Followup Setup-Add", "N", "Add Followup Setup", BsfGlobal.g_lUserId, 0, 0, 0, BsfGlobal.g_sCRMDBName); BsfGlobal.InsertLog(DateTime.Now, "Followup Setup-Add", "N", "Add Followup Setup", identity, 0, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId); getData("CallType"); } else { if (argId <= 4) { MessageBox.Show("Cant Changes"); return; } else { sSql = String.Format("Update CallType SET Description='{0}',SortId={1} WHERE CallTypeId={2}", argDesc, rowno, argId); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); cmd.ExecuteNonQuery(); //CommFun.InsertLog(DateTime.Now, "Followup Setup-Edit", "E", "Edit Followup Setup", BsfGlobal.g_lUserId, 0, 0, 0, BsfGlobal.g_sCRMDBName); BsfGlobal.InsertLog(DateTime.Now, "Followup Setup-Edit", "E", "Edit Followup Setup", argId, 0, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId); } } } else if (sType == "N") { bool bAns = UnitDirBL.FoundCallType(argId, argDesc, sType); if (bAns == true) { MessageBox.Show("Already Exists"); DGvTransView.CancelUpdateCurrentRow(); return; } if (argId == 0) { sSql = String.Format("INSERT INTO NatureMaster(Description) Values('{0}') SELECT SCOPE_IDENTITY(); ", argDesc); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); identity = Convert.ToInt16(cmd.ExecuteScalar().ToString()); cmd.Dispose(); //DGvTransView.SetRowCellValue(DGvTransView.FocusedRowHandle, "NatureId", identity); //DGvTransView.SetRowCellValue(DGvTransView.FocusedRowHandle, "SysDefault", false); sSql = String.Format("Update NatureMaster Set SortId={0} Where NatureId= {0}", identity); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); cmd.ExecuteNonQuery(); //CommFun.InsertLog(DateTime.Now, "Followup Setup-Add", "N", "Add Followup Setup", BsfGlobal.g_lUserId, 0, 0, 0, BsfGlobal.g_sCRMDBName); BsfGlobal.InsertLog(DateTime.Now, "Followup Setup-Add", "N", "Add Followup Setup", identity, 0, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId); getData("Nature"); } else { sSql = String.Format("Update NatureMaster SET Description='{0}',SortId={1} WHERE NatureId={2}", argDesc, rowno, argId); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); cmd.ExecuteNonQuery(); //CommFun.InsertLog(DateTime.Now, "Followup Setup-Edit", "E", "Edit Followup Setup", BsfGlobal.g_lUserId, 0, 0, 0, BsfGlobal.g_sCRMDBName); BsfGlobal.InsertLog(DateTime.Now, "Followup Setup-Edit", "E", "Edit Followup Setup", argId, 0, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId); } } else if (sType == "S") { bool bAns = UnitDirBL.FoundCallType(argId, argDesc, sType); if (bAns == true) { MessageBox.Show("Already Exists"); DGvTransView.CancelUpdateCurrentRow(); return; } if (argId == 0) { sSql = String.Format("INSERT INTO StatusMaster(Description) Values('{0}') SELECT SCOPE_IDENTITY();", argDesc); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); identity = Convert.ToInt16(cmd.ExecuteScalar().ToString()); cmd.Dispose(); //DGvTransView.SetRowCellValue(DGvTransView.FocusedRowHandle, "StatusId", identity); //DGvTransView.SetRowCellValue(DGvTransView.FocusedRowHandle, "SysDefault", false); sSql = String.Format("Update StatusMaster Set SortId={0} Where StatusId= {0}", identity); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); cmd.ExecuteNonQuery(); //CommFun.InsertLog(DateTime.Now, "Followup Setup-Add", "N", "Add Followup Setup", BsfGlobal.g_lUserId, 0, 0, 0, BsfGlobal.g_sCRMDBName); BsfGlobal.InsertLog(DateTime.Now, "Followup Setup-Add", "N", "Add Followup Setup", identity, 0, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId); getData("Status"); } else { sSql = String.Format("Update StatusMaster SET Description='{0}',SortId={1} WHERE StatusId={2}", argDesc, rowno, argId); cmd = new SqlCommand(sSql, BsfGlobal.OpenCRMDB()); cmd.ExecuteNonQuery(); //CommFun.InsertLog(DateTime.Now, "Followup Setup-Edit", "E", "Edit Followup Setup", BsfGlobal.g_lUserId, 0, 0, 0, BsfGlobal.g_sCRMDBName); BsfGlobal.InsertLog(DateTime.Now, "Followup Setup-Edit", "E", "Edit Followup Setup", argId, 0, 0, BsfGlobal.g_sCRMDBName, "", BsfGlobal.g_lUserId); } } }