Exemplo n.º 1
0
    protected void ClearAll()
    {
        TxtClientName.Text = "";
        TxtFirmName.Text   = "";
        TxtEMailId.Text    = "";

        TxtFDOJ.Text      = "";
        TxtTDOJ.Text      = "";
        TxtFLeftDate.Text = "";
        TxtTLeftDate.Text = "";

        var ContryDs = from c in HRMLinq.Country_Masts
                       orderby c.CountryName
                       select new { CountryId = c.Id, c.CountryName };

        ddlCountry.Items.Clear();
        ddlCountry.DataSource     = ContryDs; //BLayer.FillCountry();
        ddlCountry.DataValueField = "CountryId";
        ddlCountry.DataTextField  = "CountryName";
        ddlCountry.DataBind();
        ddlCountry.Items.Insert(0, new ListItem("--Select Country--", "0"));

        ddlState.Items.Clear();
        ddlState.Items.Insert(0, new ListItem("---Select State---", "0"));

        ddlCity.Items.Clear();
        ddlCity.Items.Insert(0, new ListItem("---Select City---", "0"));

        //ReportViewer1.ProcessingMode = ProcessingMode.Local;
        //ReportViewer1.LocalReport.ReportPath = Server.MapPath("ClientInfo.rdlc");
        ReportViewer1.Reset();

        TxtClientName.Focus();
    }
Exemplo n.º 2
0
    //protected void GridClient_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    try
    //    {
    //        HidFldId.Value = GridClient.DataKeys[GridClient.SelectedRow.RowIndex].Value.ToString();

    //        StrSql = new StringBuilder();
    //        StrSql.Length = 0;

    //        StrSql.AppendLine("Select C.Id,C.ClientName,C.FirmName,C.EMailId,C.MobNo ");
    //        StrSql.AppendLine(",Convert(Varchar(10),C.DOJ,103) As DOJ");
    //        StrSql.AppendLine(",C.CountryId,C.StateId,C.CityId");
    //        StrSql.AppendLine(",C.Address1,C.PinCode");
    //        StrSql.AppendLine(",C.Phone,Convert(Varchar(10),C.LeftDate,103) As LeftDate");
    //        StrSql.AppendLine("From Client_Mast C");
    //        StrSql.AppendLine("Where C.Id=" + int.Parse(HidFldId.Value));

    //        dtTemp = new DataTable();
    //        dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString());

    //        if (dtTemp.Rows.Count == 0)
    //        {
    //            LblMsg.Text = "Data not found";
    //            return;
    //        }

    //        TxtClientName.Text = dtTemp.Rows[0]["ClientName"].ToString();
    //        TxtFirmName.Text = dtTemp.Rows[0]["FirmName"].ToString();
    //        TxtDOJ.Text = dtTemp.Rows[0]["DOJ"].ToString();
    //        TxtEMailId.Text = dtTemp.Rows[0]["EMailId"].ToString();

    //        ddlCountry.Items.Clear();
    //        ddlCountry.DataSource = BLayer.FillCountry();
    //        ddlCountry.DataValueField = "CountryId";
    //        ddlCountry.DataTextField = "CountryName";
    //        ddlCountry.DataBind();
    //        ddlCountry.Items.Insert(0, new ListItem("--Select Country--", "0"));
    //        if (dtTemp.Rows[0]["CountryId"].ToString() != "")
    //        {
    //            ddlCountry.SelectedValue = dtTemp.Rows[0]["CountryId"].ToString();
    //        }

    //        ddlState.Items.Clear();
    //        ddlState.DataSource = BLayer.FillState(int.Parse(ddlCountry.SelectedValue));
    //        ddlState.DataValueField = "StateId";
    //        ddlState.DataTextField = "StateName";
    //        ddlState.DataBind();
    //        ddlState.Items.Insert(0, new ListItem("--Select State--", "0"));
    //        if (dtTemp.Rows[0]["StateID"].ToString() != "")
    //        {
    //            ddlState.SelectedValue = dtTemp.Rows[0]["StateID"].ToString();
    //        }

    //        ddlCity.Items.Clear();
    //        ddlCity.DataSource = BLayer.FillCity(int.Parse(ddlState.SelectedValue));
    //        ddlCity.DataValueField = "CityId";
    //        ddlCity.DataTextField = "CityName";
    //        ddlCity.DataBind();
    //        ddlCity.Items.Insert(0, new ListItem("--Select City--", "0"));
    //        if (dtTemp.Rows[0]["CityId"].ToString() != "")
    //        {
    //            ddlCity.SelectedValue = dtTemp.Rows[0]["CityId"].ToString();
    //        }

    //        TxtAddress1.Text = dtTemp.Rows[0]["Address1"].ToString();
    //        TxtPinCode.Text = dtTemp.Rows[0]["PinCode"].ToString();
    //        TxtMobNo.Text = dtTemp.Rows[0]["MobNo"].ToString();
    //        TxtPhone.Text = dtTemp.Rows[0]["Phone"].ToString();
    //        TxtLeftDate.Text = dtTemp.Rows[0]["LeftDate"].ToString();

    //        // Move to Edit Tab

    //        MyMenu.Items[0].ImageUrl = "~/Images/ViewDisable.jpg";
    //        MyMenu.Items[1].ImageUrl = "~/Images/NewOrEditEnable.jpg";
    //        MyMenu.Items[1].Selected = true;
    //        MyMultiView.ActiveViewIndex = 1;
    //    }
    //    catch (Exception ex)
    //    {
    //        Response.Write(ex.ToString());
    //    }
    //}

    protected void BtnNew_Click(object sender, EventArgs e)
    {
        try
        {
            ClearAll();
            TxtClientName.Focus();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Exemplo n.º 3
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (TxtClientName.Text.Length == 0)
            {
                //LblMsg.Text = "Client Name Is Blank, Enter Valid Name....";
                TxtClientName.Focus();
                return;
            }

            if (TxtFirmName.Text.Length == 0)
            {
                //LblMsg.Text = "Firm Name Is Blank, Enter Valid Name....";
                TxtFirmName.Focus();
                return;
            }

            if (TxtDOJ.Text.Length == 0)
            {
                //LblMsg.Text = "Date Of Join Is Blank, Enter Valid Join Date....";
                TxtDOJ.Focus();
                return;
            }

            if (TxtEMailId.Text.Length == 0)
            {
                //LblMsg.Text = "EMail Id Is Blank, Enter Valid EMail Id....";
                TxtEMailId.Focus();
                return;
            }

            if (TxtMobNo.Text.Length == 0)
            {
                //LblMsg.Text = "Mob.No Is Blank, Enter Valid Mob.No....";
                TxtMobNo.Focus();
                return;
            }

            StrSql        = new StringBuilder();
            StrSql.Length = 0;


            if (HidFldId.Value.Length == 0)
            {
                StrSql.AppendLine("Insert Into Client_Mast");
                StrSql.AppendLine("(ClientName,FirmName");
                StrSql.AppendLine(",DOJ");
                StrSql.AppendLine(",EMailId");
                StrSql.AppendLine(",CountryId,StateId,CityId");
                StrSql.AppendLine(",Address1,PinCode");
                StrSql.AppendLine(",MobNo,Phone");
                StrSql.AppendLine(",LeftDate");
                StrSql.AppendLine(",Entry_Date,Entry_Time");
                StrSql.AppendLine(",Entry_UID,UPDFLAG");
                StrSql.AppendLine(")");

                StrSql.AppendLine("Values(@ClientName,@FirmName");
                StrSql.AppendLine(",@DOJ");
                StrSql.AppendLine(",@EMailId");
                StrSql.AppendLine(",@CountryId,@StateId,@CityId");
                StrSql.AppendLine(",@Address1,@PinCode");
                StrSql.AppendLine(",@MobNo,@Phone");
                StrSql.AppendLine(",@LeftDate");
                StrSql.AppendLine(",GetDate(),Convert(VarChar,GetDate(),108)");
                StrSql.AppendLine(",@Entry_UID,0)");
            }
            else
            {
                StrSql.AppendLine("Update Client_Mast");
                StrSql.AppendLine("Set ClientName=@ClientName,FirmName=@FirmName");
                StrSql.AppendLine(",DOJ=@DOJ");
                StrSql.AppendLine(",EMailId=@EMailId");
                StrSql.AppendLine(",CountryId=@CountryId,StateId=@StateId,CityId=@CityId");
                StrSql.AppendLine(",Address1=@Address1,PinCode=@PinCode");
                StrSql.AppendLine(",MobNo=@MobNo,Phone=@Phone");
                StrSql.AppendLine(",LeftDate=@LeftDate");
                StrSql.AppendLine(",MEntry_Date=GetDate(),MEntry_Time=Convert(Varchar,GetDate(),108)");
                StrSql.AppendLine(",MEntry_UID=@Entry_UID,UPDFLAG=IsNull(UPDFlag,0)+1");
                StrSql.AppendLine("Where Id=@Id");
            }

            Cmd = new SqlCommand(StrSql.ToString(), SqlFunc.gConn);

            Cmd.Parameters.AddWithValue("@ClientName", TxtClientName.Text.Trim());
            Cmd.Parameters.AddWithValue("@FirmName", TxtFirmName.Text.Trim());

            Cmd.Parameters.AddWithValue("@DOJ", ValueConvert.ConvertDate(TxtDOJ.Text));
            Cmd.Parameters.AddWithValue("@EMailId", TxtEMailId.Text.Trim());

            if (ddlCountry.SelectedValue != "0")
            {
                Cmd.Parameters.AddWithValue("@CountryId", ddlCountry.SelectedValue);
            }
            else
            {
                Cmd.Parameters.AddWithValue("@CountryId", DBNull.Value);
            }
            if (ddlState.SelectedValue != "0")
            {
                Cmd.Parameters.AddWithValue("@StateId", ddlState.SelectedValue);
            }
            else
            {
                Cmd.Parameters.AddWithValue("@StateId", DBNull.Value);
            }
            if (ddlCity.SelectedValue != "0")
            {
                Cmd.Parameters.AddWithValue("@CityId", ddlCity.SelectedValue);
            }
            else
            {
                Cmd.Parameters.AddWithValue("@CityId", DBNull.Value);
            }
            Cmd.Parameters.AddWithValue("@Address1", TxtAddress1.Text.Trim());
            Cmd.Parameters.AddWithValue("@PinCode", TxtPinCode.Text.Trim());
            Cmd.Parameters.AddWithValue("@MobNo", TxtMobNo.Text.Trim());
            Cmd.Parameters.AddWithValue("@Phone", TxtPhone.Text.Trim());
            if (TxtLeftDate.Text.Length != 0)
            {
                Cmd.Parameters.AddWithValue("@LeftDate", ValueConvert.ConvertDate(TxtLeftDate.Text));
            }
            else
            {
                Cmd.Parameters.AddWithValue("@LeftDate", DBNull.Value);
            }

            Cmd.Parameters.AddWithValue("@Entry_UID", HidFldUID.Value.ToString());

            if (HidFldId.Value.Length == 0)
            {
                SqlFunc.ExecuteNonQuery(Cmd);
                LblMsg.Text = "Client added successfully";
            }
            else
            {
                Cmd.Parameters.AddWithValue("@ID", HidFldId.Value.ToString());

                SqlFunc.ExecuteNonQuery(Cmd);
                LblMsg.Text = "Client updated successfully";
            }

            FillGrid();

            ClearAll();

            // Move to View Tab
            MyMenu.Items[0].Selected    = true;
            MyMenu.Items[0].ImageUrl    = "~/Images/ViewEnable.jpg";
            MyMultiView.ActiveViewIndex = 0;
            MyMenu.Items[1].ImageUrl    = "~/Images/NewOrEditDisable.jpg";
        }
        catch (Exception ex)
        {
            throw(ex);
        }
    }