then what should i change in this code my main problem is here only near if (ds.Tables[0].Rows.Count > 0)
{
if (HasFile == false)
{
lblerrmsg.Visible = true;
lblerrmsg.Text = "File Already Exist ...!";
return false;
}
else
{
lblerrmsg.Visible = true;
lblfname.Text = "";
lbldocname.Text = "";
pnl1.Visible = true;
btnupdate.Enabled = false;
lblerrmsg.Visible = true;
btnadd.Enabled = true;
string Subjects = "select ID, Subject from Subjects where Module = '" + null + "'";
BindDropDownList(ddlsubjname, Subjects, "Subject", "ID", "--Select--");
lblerrmsg.Text = "File Already Exist ...!";
if (IsPostBack)
{
BindGrid();
}
Clear();
return false;
}
}
flag1 = true;
return flag1;
problem is at above code and below is original code
private bool CheckFileExist(string SubjName, string FileName, string Stype, string PhysiName, string DocName, string TempFilName, string DraftFileName, bool HasFile, string Type, string DraftName)
{
var flag1 = false;
string qry = string.Empty;
if (Type == "Add")
{
if (Stype == "Draft")
{
qry = "select ID,SubjectID,auditoName from SubjectItems where (SubjectID='" + SubjName + "' and auditoName='" + FileName + "' and AuditoType='" + Stype + "' and Physician='" + PhysiName + "') or (BaseDocumentName='" + DocName + "') or( DraftDocumentName='" + DraftName + "') ";
}
else
{
qry = "select ID,SubjectID,auditoName from SubjectItems where (SubjectID='" + SubjName + "' and auditoName='" + FileName + "' and AuditoType='" + Stype + "' and Physician='" + PhysiName + "') or BaseDocumentName='" + DocName + "' ";
}
}
else
{
if (Stype == "Draft")
{
qry = "select ID,SubjectID,auditoName from SubjectItems where (BaseDocumentName = '" + DocName + "' and ID <> " + Session["ID"] + ") or (DraftDocumentName = '" + DraftName + "' and ID <> " + Session["ID"] + ") or (SubjectID='" + SubjName + "' and auditoName='" + FileName + "' and AuditoType='" + Stype + "' and Physician='" + PhysiName + "' and ID <> " + Session["ID"] + ")";
}
else
{
qry = "select ID,SubjectID,auditoName from SubjectItems where (BaseDocumentName = '" + DocName + "' and ID <> " + Session["ID"] + ") or (SubjectID='" + SubjName + "' and auditoName='" + FileName + "' and AuditoType='" + Stype + "' and Physician='" + PhysiName + "' and ID <> " + Session["ID"] + ")";
}
}
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
if (HasFile == false)
{
lblerrmsg.Visible = true;
lblerrmsg.Text = "File Already Exist ...!";
return false;
}
else
{
lblerrmsg.Visible = true;
lblfname.Text = "";
lbldocname.Text = "";
pnl1.Visible = true;
btnupdate.Enabled = false;
lblerrmsg.Visible = true;
btnadd.Enabled = true;
string Subjects = "select ID, Subject from Subjects where Module = '" + null + "'";
BindDropDownList(ddlsubjname, Subjects, "Subject", "ID", "--Select--");
lblerrmsg.Text = "File Already Exist ...!";
if (IsPostBack)
{
BindGrid();
}
Clear();
return false;
}
}
flag1 = true;
return flag1;
}