protected void BtnNew_Click(object sender, EventArgs e) { try { ClearAll(); DDLClientName.Focus(); } catch (Exception ex) { Response.Write(ex.ToString()); } }
protected void BtnSave_Click(object sender, EventArgs e) { try { if (DDLClientName.SelectedValue == "0") { //LblMsg.Text = "Select Client..."; DDLClientName.Focus(); return; } if (TxtPrjName.Text.Length == 0) { //LblMsg.Text = "Enter Project Name..."; TxtPrjName.Focus(); return; } StrSql = new StringBuilder(); StrSql.Length = 0; if (HidFldId.Value.Length == 0) { StrSql.AppendLine("Insert Into Project_Mast"); StrSql.AppendLine("(ClientId,ProjectName"); StrSql.AppendLine(",StartDate,EndDate"); StrSql.AppendLine(",ProjctStatus,Remark"); StrSql.AppendLine(",Entry_Date,Entry_Time"); StrSql.AppendLine(",Entry_UID,UPDFLAG)"); StrSql.AppendLine("Values"); StrSql.AppendLine("(@ClientId,@ProjectName"); StrSql.AppendLine(",@StartDate,@EndDate"); StrSql.AppendLine(",@ProjctStatus,@Remark"); StrSql.AppendLine(",GetDate(),CONVERT(Varchar,GETDATE(),108)"); StrSql.AppendLine(",@Entry_UID,0)"); } else { StrSql.AppendLine("Update Project_Mast"); StrSql.AppendLine("Set ClientId=@ClientId"); StrSql.AppendLine(",ProjectName=@ProjectName"); StrSql.AppendLine(",StartDate=@StartDate"); StrSql.AppendLine(",EndDate=@EndDate"); StrSql.AppendLine(",ProjctStatus=@ProjctStatus"); StrSql.AppendLine(",Remark=@Remark"); StrSql.AppendLine(",UPDFLAG=ISNULL(UPDFLAG,0)+1"); StrSql.AppendLine(",MEntry_Date=GETDATE()"); StrSql.AppendLine(",MEntry_Time=CONVERT(Varchar,GETDATE(),108)"); StrSql.AppendLine(",MEntry_UID=@Entry_UId"); StrSql.AppendLine("Where Id=@Id"); } Cmd = new SqlCommand(StrSql.ToString(), SqlFunc.gConn); if (DDLClientName.SelectedValue != "0") { Cmd.Parameters.AddWithValue("@ClientId", DDLClientName.SelectedValue); } else { Cmd.Parameters.AddWithValue("@ClientId", DBNull.Value); } Cmd.Parameters.AddWithValue("@ProjectName", TxtPrjName.Text); if (TxtStartDate.Text.Length != 0) { Cmd.Parameters.AddWithValue("@StartDate", ValueConvert.ConvertDate(TxtStartDate.Text)); } else { Cmd.Parameters.AddWithValue("@StartDate", DBNull.Value); } if (TxtEndDate.Text.Length != 0) { Cmd.Parameters.AddWithValue("@EndDate", ValueConvert.ConvertDate(TxtEndDate.Text)); } else { Cmd.Parameters.AddWithValue("@EndDate", DBNull.Value); } if (ddlPrjStatus.SelectedValue != "0") { Cmd.Parameters.AddWithValue("@ProjctStatus", ddlPrjStatus.SelectedValue); } else { Cmd.Parameters.AddWithValue("@ProjctStatus", DBNull.Value); } Cmd.Parameters.AddWithValue("@Remark", TxtRemark.Text); Cmd.Parameters.AddWithValue("@Entry_UID", HidFldUID.Value.ToString()); if (HidFldId.Value.Length == 0) { SqlFunc.ExecuteNonQuery(Cmd); LblMsg.Text = "Entry insert successfully..."; } else { Cmd.Parameters.AddWithValue("@Id", int.Parse(HidFldId.Value)); SqlFunc.ExecuteNonQuery(Cmd); LblMsg.Text = "Entry update successfully..."; } FillGrid(); ClearAll(); MyMenu.Items[0].Selected = true; MyMenu.Items[0].ImageUrl = "~/Images/ViewEnable.jpg"; MyMenu.Items[1].ImageUrl = "~/Images/NewOrEditDisable.jpg"; MyMultiView.ActiveViewIndex = 0; } catch (Exception ex) { Response.Write(ex.ToString()); } }