public void BindTrip(Int64 Id)
    {
        collectiontrip objcollectiontrip = (new Cls_collectiontrip_b().SelectById(Id));

        if (objcollectiontrip != null)
        {
            lstemployee.SelectedValue = objcollectiontrip.empid.ToString();
            hfempid.Value             = objcollectiontrip.empid.ToString();
            lstday.SelectedValue      = objcollectiontrip.weekday;
            hfday.Value = objcollectiontrip.weekday;
            //lstCity.SelectedValue = objcollectiontrip.cityname;
            hfcity.Value = objcollectiontrip.cityname;
            String[] cityid = objcollectiontrip.cityname.Split(',');
            foreach (string i in cityid)
            {
                lstCity.Items.FindByValue(i).Selected = true;
            }

            //foreach (var item in lstCity.Items)
            //{
            //    if (cityid.Contains(item))
            //        item.Selected = true;
            //}
        }
    }
예제 #2
0
        public collectiontrip SelectById(Int64 bankid)
        {
            SqlDataAdapter da;
            DataSet        ds = new DataSet();
            collectiontrip objcollectiontrip = new collectiontrip();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "collectiontrip_SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@id", bankid);
                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0] != null)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                {
                                    // id, weekday, cityname, empid, empname, isdeleted

                                    objcollectiontrip.id       = Convert.ToInt64(ds.Tables[0].Rows[0]["id"]);
                                    objcollectiontrip.empid    = Convert.ToInt64(ds.Tables[0].Rows[0]["empid"]);
                                    objcollectiontrip.weekday  = Convert.ToString(ds.Tables[0].Rows[0]["weekday"]);
                                    objcollectiontrip.cityname = Convert.ToString(ds.Tables[0].Rows[0]["cityname"]);
                                    objcollectiontrip.empname  = Convert.ToString(ds.Tables[0].Rows[0]["empname"]);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objcollectiontrip);
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64          Result            = 0;
        collectiontrip objcollectiontrip = new collectiontrip();


        objcollectiontrip.cityname = hfcity.Value;
        objcollectiontrip.empid    = Convert.ToInt64(hfempid.Value);
        objcollectiontrip.weekday  = hfday.Value;



        if (Request.QueryString["id"] != null)
        {
            objcollectiontrip.id = Convert.ToInt32(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));

            Result = (new Cls_collectiontrip_b().Update(objcollectiontrip));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/managecollectiontrip.aspx?mode=u"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Trip Not Updated";
                BindTrip(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)));
            }
        }
        else
        {
            Result = (new Cls_collectiontrip_b().Insert(objcollectiontrip));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/managecollectiontrip.aspx?mode=i"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Trip Not Inserted";
            }
        }
    }
예제 #4
0
        public Int64 Insert(collectiontrip objcollectiontrip)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "collectiontrip_Insert";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;


                // id, weekday, cityname, empid, empname, isdeleted

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@id";
                param.Value         = objcollectiontrip.id;
                param.SqlDbType     = SqlDbType.Int;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@weekday", objcollectiontrip.weekday);
                cmd.Parameters.AddWithValue("@cityname", objcollectiontrip.cityname);
                cmd.Parameters.AddWithValue("@empid", objcollectiontrip.empid);



                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }