public ActionResult Insert_Data(CommanUserMaster CUH)
        {
            try
            {
                ViewBag.Message = "";
                ViewBag.Event = "";
                DataSet result = _objCM.insert_data_UserMaster(CUH);
                if (result != null)
                {
                    ViewBag.Message = result.Tables[0].Rows[0]["msg"].ToString();
                    if (result.Tables[0].Rows[0]["Help"].ToString() == "Save" || result.Tables[0].Rows[0]["Help"].ToString() == "Update")
                    { 
                        ViewBag.Event = "success";
                        ViewBag.Srno = result.Tables[0].Rows[0]["SrNo"].ToString();
                    }
                    else if (result.Tables[0].Rows[0]["Help"].ToString() == "Duplicate")
                    { 
                        ViewBag.Event = "error"; 
                    }
                }
                var result1 = ViewBag.Message;

                return Json(new { success = result1, Event = ViewBag.Event, srno = ViewBag.Srno }, JsonRequestBehavior.AllowGet);

            }
            catch (Exception)
            {

                throw;
            }


        }
        public DataSet insert_data_UserMaster(CommanUserMaster CUH)
        {
            try
            {
                _cn.Open();
                SqlCommand _cmd = new SqlCommand("sp_save_usermaster", _cn);
                _cmd.CommandType = CommandType.StoredProcedure;

                _cmd.Parameters.AddWithValue("@Srno", CUH.USrno);

                _cmd.Parameters.AddWithValue("@xmaster", CUH.Uxmaster);
                _cmd.Parameters.AddWithValue("@xcode", CUH.Uxcode);
                _cmd.Parameters.AddWithValue("@xname", CUH.Uxname);

                _cmd.Parameters.AddWithValue("@IsActive", CUH.UIsActive);
                _cmd.Parameters.AddWithValue("@Remark", CUH.URemark);

                if (CUH.Uxlink != null)
                {
                    _cmd.Parameters.AddWithValue("@xlink", CUH.Uxlink);
                }
                else { _cmd.Parameters.AddWithValue("@xlink", "0"); }

                if (CUH.Uxcross != null)
                {
                    _cmd.Parameters.AddWithValue("@xcross", CUH.Uxcross);
                }
                else { _cmd.Parameters.AddWithValue("@xcross", "0"); }
                if (CUH.Uxcross1 != null)
                {
                    _cmd.Parameters.AddWithValue("@xcross1", CUH.Uxcross1);
                }
                else { _cmd.Parameters.AddWithValue("@xcross1", "0"); }

                if (CUH.Uxcross2 != null)
                {
                    _cmd.Parameters.AddWithValue("@xcross2", CUH.Uxcross2);
                }
                else { _cmd.Parameters.AddWithValue("@xcross2", "0"); }

                if (CUH.Uxcross3 != null)
                {
                    _cmd.Parameters.AddWithValue("@xcross3 ", CUH.Uxcross3);
                }
                else { _cmd.Parameters.AddWithValue("@xcross3", "0"); }
                if (CUH.Uxcross4 != null)
                {
                    _cmd.Parameters.AddWithValue("@xcross4", CUH.Uxcross4);
                }
                else { _cmd.Parameters.AddWithValue("@xcross4", "0"); }


                if (CUH.Uxreference1 != null)
                {
                    _cmd.Parameters.AddWithValue("@xreference1 ", CUH.Uxreference1);
                }
                else { _cmd.Parameters.AddWithValue("@xreference1", ""); }


                if (CUH.Uxreference2 != null)
                {
                    _cmd.Parameters.AddWithValue("@xreference2 ", CUH.Uxreference2);
                }
                else { _cmd.Parameters.AddWithValue("@xreference2", ""); }

                if (CUH.Uxreference3 != null)
                {
                    _cmd.Parameters.AddWithValue("@xreference3 ", CUH.Uxreference3);
                }
                else { _cmd.Parameters.AddWithValue("@xreference3", ""); }

                if (CUH.Uxreference4 != null)
                {
                    _cmd.Parameters.AddWithValue("@xreference4 ", CUH.Uxreference4);
                }
                else { _cmd.Parameters.AddWithValue("@xreference4", ""); }

                if (CUH.Uxreference5 != null)
                {
                    _cmd.Parameters.AddWithValue("@xreference5 ", CUH.Uxreference5);
                }
                else { _cmd.Parameters.AddWithValue("@xreference5", ""); }

                if (CUH.Uxreference6 != null)
                {
                    _cmd.Parameters.AddWithValue("@xreference6 ", CUH.Uxreference6);
                }
                else { _cmd.Parameters.AddWithValue("@xreference6", ""); }


                _cmd.Parameters.AddWithValue("@xdetail ", CUH.Uxdetail);

                _cmd.Parameters.AddWithValue("@Attribute1", CUH.UAttribute1);
                _cmd.Parameters.AddWithValue("@Attribute2", CUH.UAttribute2);
                _cmd.Parameters.AddWithValue("@Attribute3", CUH.UAttribute3);
                _cmd.Parameters.AddWithValue("@Attribute4", CUH.UAttribute4);
                _cmd.Parameters.AddWithValue("@Attribute5", CUH.UAttribute5);
                _cmd.Parameters.AddWithValue("@Attribute6", CUH.UAttribute6);
                _cmd.Parameters.AddWithValue("@Attribute7", CUH.UAttribute7);
                _cmd.Parameters.AddWithValue("@Attribute8", CUH.UAttribute8);
                _cmd.Parameters.AddWithValue("@Attribute9", CUH.UAttribute9);
                _cmd.Parameters.AddWithValue("@Attribute10", CUH.UAttribute10);

                _cmd.Parameters.AddWithValue("@Rating1", CUH.URating1);
                _cmd.Parameters.AddWithValue("@Rating2", CUH.URating2);
                _cmd.Parameters.AddWithValue("@Rating3", CUH.URating3);

                if (CUH.UDate1 == null)
                {
                    _cmd.Parameters.AddWithValue("@Date1", DBNull.Value);
                }
                else
                {
                    _cmd.Parameters.AddWithValue("@Date1", DateTime.ParseExact(CUH.UDate1, "dd/MM/yyyy", null));
                }

                if (CUH.UDate2 == null)
                {
                    _cmd.Parameters.AddWithValue("@Date2", DBNull.Value);
                }
                else
                {
                    _cmd.Parameters.AddWithValue("@Date2", DateTime.ParseExact(CUH.UDate2, "dd/MM/yyyy", null));
                }


                if (CUH.UDate3 == null)
                {
                    _cmd.Parameters.AddWithValue("@Date3", DBNull.Value);
                }
                else
                {
                    _cmd.Parameters.AddWithValue("@Date3", DateTime.ParseExact(CUH.UDate3, "dd/MM/yyyy", null));
                }


                _cmd.Parameters.AddWithValue("@Email1", CUH.UEmail1);
                _cmd.Parameters.AddWithValue("@Email2", CUH.UEmail2);
                _cmd.Parameters.AddWithValue("@Email3", CUH.UEmail3);

                _cmd.Parameters.AddWithValue("@Amount", CUH.UAmount);
                _cmd.Parameters.AddWithValue("@Amount2", CUH.UAmount2);
                _cmd.Parameters.AddWithValue("@Amount3", CUH.UAmount3);

                if (CUH.UTime1 == null)
                {
                    _cmd.Parameters.AddWithValue("@Time1", DBNull.Value);
                }
                else
                {
                    _cmd.Parameters.AddWithValue("@Time1", CUH.UTime1);
                }


                if (CUH.UTime2 == null)
                {
                    _cmd.Parameters.AddWithValue("@Time2", DBNull.Value);
                }
                else
                {
                    _cmd.Parameters.AddWithValue("@Time2", CUH.UTime1);
                }

                _cmd.Parameters.AddWithValue("@Html", CUH.UHtml);
                _cmd.Parameters.AddWithValue("@Upload", CUH.UUpload);
                _cmd.Parameters.AddWithValue("@TextArea", CUH.UTextArea);

                _cmd.Parameters.AddWithValue("@MultiSelect1", CUH.UMultiSelect1);
                _cmd.Parameters.AddWithValue("@MultiSelect2", CUH.UMultiSelect2);
                _cmd.Parameters.AddWithValue("@MultiSelect3", CUH.UMultiSelect3);
                _cmd.Parameters.AddWithValue("@MultiSelect4", CUH.UMultiSelect4);
                _cmd.Parameters.AddWithValue("@MultiSelect5", CUH.UMultiSelect5);

                _cmd.Parameters.AddWithValue("@CreatedBy", CUH.CreatedBy);

                _cmd.Parameters.AddWithValue("@CorpcentreBy", CUH.CorpcentreBy);
                _cmd.Parameters.AddWithValue("@UnitCorpBy", CUH.UnitCorpBy);
                _cmd.Parameters.AddWithValue("@TerminalBy", CUH.TerminalBy);
                _cmd.Parameters.AddWithValue("@BranchBy", CUH.BranchBy);
                _cmd.Parameters.AddWithValue("@UserId", CUH.CreatedBy);

                // int i = _cmd.ExecuteNonQuery();
                // return i;
                SqlDataAdapter _adp = new SqlDataAdapter(_cmd);
                DataSet _ds = new DataSet();
                _adp.Fill(_ds);
                _adp.Dispose();
                _cmd.Dispose();
                return _ds;



            }
            catch
            {
                throw;
            }
            finally
            {
                _cn.Close();
                _cn.Dispose();
            }

        }