Example #1
0
        public Int64 InsertMultpleFromCity(Int64 HeadIdno, System.Web.UI.WebControls.CheckBoxList chklistFromcity)
        {
            Int64 fromcityDetlIdno = 0;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    for (int i = 0; i < chklistFromcity.Items.Count; i++)
                    {
                        if (chklistFromcity.Items[i].Selected == true)
                        {
                            tblFrmCityDetl obj = new tblFrmCityDetl();
                            obj.User_Idno    = HeadIdno;
                            obj.FrmCity_Idno = Convert.ToInt32(chklistFromcity.Items[i].Value);
                            db.AddTotblFrmCityDetls(obj);
                            db.SaveChanges();
                            fromcityDetlIdno = obj.FrmCityDetl_Idno;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(fromcityDetlIdno);
        }
Example #2
0
        public Int64 UpdateMultpleFromCity(Int64 HeadIdno, System.Web.UI.WebControls.CheckBoxList chklistFromcity)
        {
            Int64 ID = 0;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    List <tblFrmCityDetl> objDetls = db.tblFrmCityDetls.Where(pcd => pcd.User_Idno == HeadIdno).ToList();
                    if (objDetls.Count > 0)
                    {
                        foreach (tblFrmCityDetl pcd in objDetls)
                        {
                            db.DeleteObject(pcd);
                            db.SaveChanges();
                        }
                    }
                    for (int i = 0; i < chklistFromcity.Items.Count; i++)
                    {
                        if (chklistFromcity.Items[i].Selected == true)
                        {
                            tblFrmCityDetl obj = new tblFrmCityDetl();
                            obj.User_Idno    = HeadIdno;
                            obj.FrmCity_Idno = Convert.ToInt32(chklistFromcity.Items[i].Value);
                            db.AddTotblFrmCityDetls(obj);
                            db.SaveChanges();
                            ID = obj.FrmCityDetl_Idno;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(ID);
        }