Exemplo n.º 1
0
        public static string GetCountersT(string s)
        {
            int           o  = (int)Mydb.ExecuteScalar("select top 1  OBJECT_ID from VW_ROOMS where NUMBER=@s", new SqlParameter[] { new SqlParameter("@s", s) }, CommandType.Text);
            DataTable     dt = Mydb.ExecuteReadertoDataTable("select * from VW_METERS where OBJECT_ID=@o and ROOM_NUMBER=(select ROOM_ID from PER_SCORE where SCORE_ID=@s)", new SqlParameter[] { new SqlParameter("@o", o), new SqlParameter("@s", s) }, CommandType.Text);
            List <METERS> ms = new List <METERS>();

            foreach (DataRow item in dt.Rows)
            {
                METERS m = new METERS();
                m.AMUNT_TARIF   = item["AMUNT_TARIF"].ToString();
                m.LOG_IN_ID     = item["LOG_IN_ID"].ToString();
                m.METERS_ID     = item["METERS_ID"].ToString();
                m.METERS_NUMBER = item["METERS_NUMBER"].ToString();
                m.NEXT_DATE     = item["NEXT_DATE"].ToString();
                m.OBJECT_ID     = item["OBJECT_ID"].ToString();
                m.PREVIOUS_DATE = item["PREVIOUS_DATE"].ToString();
                m.ROOM_NUMBER   = item["ROOM_NUMBER"].ToString();
                m.ROOM_TYPE     = item["ROOM_TYPE"].ToString();
                m.ROOM_TYPE_ID  = item["ROOM_TYPE_ID"].ToString();
                m.SCORE_ID      = item["SCORE_ID"].ToString();
                m.TYPE          = item["TYPE"].ToString();
                m.TYPE_ID       = item["TYPE"].ToString();
                ms.Add(m);
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            return(js.Serialize(ms));
        }
Exemplo n.º 2
0
        public static string AddInfo(int McId, List <DOC_FOR_MC> dc)
        {
            foreach (DOC_FOR_MC item in dc)
            {
                if (item.KAT_ID != 0)
                {
                    int CounOfDoc = (int)Mydb.ExecuteScalar("select COUNT(*) from DOC_FOR_MC where D_URL=@url and MC_ID=@mc", new SqlParameter[] { new SqlParameter("@url", item.D_URL), new SqlParameter("@mc", McId) }, CommandType.Text);
                    if (CounOfDoc == 0)
                    {
                        // Mydb.ExecuteNoNQuery("delete from DOC_FOR_MC where MC_ID=@mc", new SqlParameter[] { new SqlParameter("@mc", McId) }, CommandType.Text);
                        Mydb.ExecuteNoNQuery("insert into  DOC_FOR_MC (D_NAME,D_URL,KAT_ID,MC_ID) values (@dnm,@durl,@kid,@mc)", new SqlParameter[] { new SqlParameter("@dnm", item.D_NAME), new SqlParameter("@durl", item.D_URL), new SqlParameter("@kid", item.KAT_ID), new SqlParameter("@mc", McId) }, CommandType.Text);
                    }
                }
                //else
                //{
                //    Mydb.ExecuteNoNQuery("delete from DOC_FOR_MC where MC_ID=@mc", new SqlParameter[] { new SqlParameter("@mc", McId) }, CommandType.Text);
                //}
            }


            //foreach (DOC_FOR_MC item in dcRemove)
            //{
            //if (item.D_NAME=="Udal")
            //{
            //    Mydb.ExecuteNoNQuery("delete from DOC_FOR_MC where D_URL=@d", new SqlParameter[] { new SqlParameter("@d", item.D_URL) }, CommandType.Text);
            //}

            //}


            return("");
        }
        public static string LoginIdentity(string Id_, string isTenant, string role)
        {
            string returnvalue = null;

            try
            {
                if (isTenant == "false")
                {
                    /*
                     * Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "2"), new SqlParameter("@lg", Id) }, CommandType.StoredProcedure);*/
                    if (role != "УК")
                    {
                        returnvalue = UK_Login(Id_);
                    }
                    else
                    {
                        int CountOfMailAsClient = Convert.ToInt32(Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "6"), new SqlParameter("@mail", Id_) }, CommandType.StoredProcedure));

                        if (CountOfMailAsClient == 0)
                        {
                            Mydb.ExecuteNoNQuery("InsertNewClient_T", new SqlParameter[] { new SqlParameter("@mail", Id_) }, CommandType.StoredProcedure);

                            returnvalue = UK_Login(Id_);
                        }
                        else
                        {
                            returnvalue = UK_Login(Id_);
                        }
                    }
                }
                else if (isTenant == "true")
                {
                    //Mydb.ExecuteAsJson("LoginSecond", new SqlParameter[] { new SqlParameter("@sc", Id_), new SqlParameter("@pass", pass) }, CommandType.StoredProcedure)
                    returnvalue = Mydb.ExecuteAsJson("TestDB.dbo.sp_QUICK_API_get_accounts_by_device1", new SqlParameter[] { new SqlParameter("@device_id", Id_) }, CommandType.StoredProcedure);
                }
            }
            catch (Exception ex)
            {
                returnvalue = "{\"result\" : \"ErrorIdendity\"}";
            }

            /*
             * return Redirect(AppConstants.AuthServer() + "/connect/endsession?id_token_hint=" + idToken + "&post_logout_redirect_uri=" + AppConstants.ClientServer() + "/signout-callback-oidc");
             */


            //HttpContext.Current.Response.Redirect("https://upravbot.ru/IDS4/Account/Logout?logoutId=CfDJ8JQq6V4gQ1xPva8MeQadqxUh3pMtraOr8jUvW3qBRzq9wjZC_7fNFZKIYrQJb94_dXsQJdLY64yybb8ZktHoTlmfzsLBfLLKRHIAuq7no_fY4fV35KwYxS6yGoQ10iGckHDmBjHS6pJcM8SwTA141e9htZFEwmiA1BQ9klespO6JcD4xZLTWbHbKm9N0juHicGdGySaC0TS5WQBsdJ3CxhDQeAt9lmcNZLTlv-2zOS8aX1bnW3p_UkLyOOszvEij3SsQSdcxo4GzSMW6UJ5ZhVBO9PizBVpxKTgKf-0ntb1_EMTxBC20xBY1h_foAP_vjsAyt2a8mEFSxRdZRcjiBIM");
            //HttpContext.Current.Response.Cookies.Remove("cookie");
            //HttpContext.Current.Response.Cookies["cookie"].Expires = DateTime.Now.AddDays(-1);
            //HttpContext.Current.GetOwinContext().Authentication.SignOut("Cookies");
            //HttpContext.Current.GetOwinContext().Authentication.SignOut("oidc");
            //HttpContext.Current.GetOwinContext().Authentication.SignOut();
            //  HttpContext.Current.GetOwinContext().Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType);
            // examplefunction();
            return(returnvalue);
        }
Exemplo n.º 4
0
        public static string MakeZakrit(int rid, string rst, string sm)
        {
            Mydb.ExecuteNoNQuery("update REQUEST set STATUS_ID=5 where REQUEST_ID=@rid", new SqlParameter[] { new SqlParameter("@rid", rid) }, CommandType.Text);

            Mydb.ExecuteNoNQuery("insert into REQUEST_STATUS_TEXT (RS_TEXT,RS_SMILE) values (@rst,@rsm)", new SqlParameter[] { new SqlParameter("@rst", rst), new SqlParameter("@rsm", sm) }, CommandType.Text);

            int LastId = (int)Mydb.ExecuteScalar(" select top 1 RST_ID from REQUEST_STATUS_TEXT order by RST_ID desc", new SqlParameter[] { }, CommandType.Text);

            Mydb.ExecuteNoNQuery("insert into REQUEST_STATUS_FILE (REQUEST_ID,FILE_ADRESS,RST_ID)values (@r_id,@fs,@rst)", new SqlParameter[] { new SqlParameter("@r_id", rid), new SqlParameter("@fs", "0"), new SqlParameter("@rst", LastId) }, CommandType.Text);
            return("{\"result\" : \"ok\"}");
        }
Exemplo n.º 5
0
        public static string SecondLogin(string score, string Pass)
        {
            string result = "";
            string msPass = (string)Mydb.ExecuteScalar("select PASS from PER_SCORE where SCORE_ID=@s", new SqlParameter[] { new SqlParameter("@s", score) }, CommandType.Text);

            if (msPass == Pass)
            {
                result = "{\"result\" : \"0\"}";
            }
            else
            {
                result = "{\"result\" : \"1\"}";
            }
            return(result);
        }
Exemplo n.º 6
0
        public static string CheckRmNum(int ObjId)
        {
            int    rmNum  = (int)Mydb.ExecuteScalar("select count(ROOM_NUMBER) from Room where OBJECT_ID=@ObjId", new SqlParameter[] { new SqlParameter("@ObjId", ObjId) }, CommandType.Text);
            string result = "";

            if (rmNum != 0)
            {
                result = "{\"result\" : \"" + rmNum + "\"}";
            }
            else
            {
                result = "{\"result\" : \"0\"}";
            }
            return(result);
        }
Exemplo n.º 7
0
        public static string getObjectId(string adr)
        {
            string Result = "";
            int    count  = (int)Mydb.ExecuteScalar("select count (*) from OBJECT where  OBJECT_ADRESS=@adr", new SqlParameter[] { new SqlParameter("@adr", adr) }, CommandType.Text);

            if (count != 0)
            {
                string ObjId = Mydb.ExecuteScalar("select OBJECT_ID from OBJECT where OBJECT_ADRESS=@adr", new SqlParameter[] { new SqlParameter("@adr", adr) }, CommandType.Text).ToString();
                Result = "{\"result\" : \"" + ObjId + "\"}";
            }
            else
            {
                Result = "{\"result\" : \"0\"}";
            }
            return(Result);
        }
Exemplo n.º 8
0
        public static string CheckPers(string pers)
        {
            int    Count  = (int)Mydb.ExecuteScalar("select COUNT(*) from PER_SCORE where NUMBER=@pers", new SqlParameter[] { new SqlParameter("@pers", pers) }, CommandType.Text);
            string result = "";

            if (Count == 0)
            {
                result = "{\"result\" : \"0\"}";
            }
            else
            {
                result = "{\"result\" : \"1\"}";
            }

            return(result);
        }
Exemplo n.º 9
0
        public static string ChangePass_(int Id, string Pass)
        {
            Pass = GetMd5HashData(Pass);
            Mydb.ExecuteNoNQuery("update ACCOUNT set PASSWORD=@p where CLIENT_ID=@id and LOGIN is null", new SqlParameter[] { new SqlParameter("@p", Pass), new SqlParameter("@id", Id) }, CommandType.Text);
            int LogId = (int)Mydb.ExecuteScalar("select LOG_IN_ID from ACCOUNT where CLIENT_ID=@c", new SqlParameter[] { new SqlParameter("@c", Id) }, CommandType.Text);

            Mydb.ExecuteNoNQuery("update CLIENT set  GUID=NEWID() where CLIENT_ID=@Id", new SqlParameter[] { new SqlParameter("@Id", Id) }, CommandType.Text);
            Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                new SqlParameter("@EVENT_TYPE", "Восстановление пароля"),
                new SqlParameter("@EVENT_STATUS", "Систем"),
                new SqlParameter("@EVENT_ROLE", "Администратор"),
                new SqlParameter("@EVENT_MODULE", "Клиентское администрирование"),
                new SqlParameter("@EVENT_MESSAGE", "Пользователь  запросил (" + LogId + ") Восстановление пароля"),
                new SqlParameter("@EVENT_MAKER", LogId)
            }, CommandType.StoredProcedure);
            return("{\"result\" : \"1\"}");
        }
 public static string ControlAndSave(string mail, int TipOrg, string Pass)
 {
     try
     {
         int countOfmail = (int)Mydb.ExecuteScalar("select COUNT(*) from ACCOUNT where E_MAIL =@mail", new SqlParameter[] { new SqlParameter("@mail", mail) }, CommandType.Text);
         if (countOfmail == 0)
         {
             Mydb.ExecuteNoNQuery("insert into CLIENT (ATTRIBUTE_ID,VERIFICATION_) values(@ID,@verf)", new SqlParameter[] { new SqlParameter("@ID", TipOrg), new SqlParameter("@verf", false) }, CommandType.Text);
             int LastClientId = (int)Mydb.ExecuteScalar("SELECT TOP 1 CLIENT_ID FROM CLIENT ORDER BY CLIENT_ID DESC", new SqlParameter[] { }, CommandType.Text);
             Mydb.ExecuteNoNQuery("insert into ACCOUNT(E_MAIL,PASSWORD,CLIENT_ID) values(@mail,@pass,@Cl_ID)", new SqlParameter[] { new SqlParameter("@mail", mail), new SqlParameter("@pass", GetMd5HashData(Pass)), new SqlParameter("@Cl_ID", LastClientId) }, CommandType.Text);
             string guid   = Mydb.ExecuteScalar("select GUID from CLIENT where CLIENT_ID=(select CLIENT_ID from ACCOUNT where E_MAIL=@EmailC)", new SqlParameter[] { new SqlParameter("@EmailC", mail) }, CommandType.Text).ToString();
             string CLient = Mydb.ExecuteScalar("select CLIENT_ID from ACCOUNT where E_MAIL=@mailC", new SqlParameter[] { new SqlParameter("@mailC", mail) }, CommandType.Text).ToString();
             string LogId  = Mydb.ExecuteScalar("select LOG_IN_ID from ACCOUNT where E_MAIL=@mailC", new SqlParameter[] { new SqlParameter("@mailC", mail) }, CommandType.Text).ToString();
             //string RolName = "Нечего";
             //string ModulName = "Нечего";
             //if (role == "4")
             //{
             //    ModulName = "Клиентское администрирование";
             //    RolName = "Администратор";
             //}
             //if (role == "3")
             //{
             //    ModulName = "Диспетчерская";
             //    RolName = "Диспетчер";
             //}
             Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                 new SqlParameter("@EVENT_TYPE", "Регистрация"),
                 new SqlParameter("@EVENT_STATUS", "Систем"),
                 new SqlParameter("@EVENT_ROLE", "Администратор"),
                 new SqlParameter("@EVENT_MODULE", "Клиентское администрирование"),
                 new SqlParameter("@EVENT_MESSAGE", "Зарегистрирован новый пользователь (email: " + mail + ")"),
                 new SqlParameter("@EVENT_MAKER", LogId)
             }, CommandType.StoredProcedure);
             return("{\"result\" : \"2\",\"guid\" : \"" + guid + "\",\"Id\" : \"" + CLient + "\",\"logId\":\"" + LogId + "\"}");
         }
         else
         {
             return("{\"result\" : \"1\"}");
         }
     }
     catch (Exception e)
     {
         return("{\" ERROR\" : \"" + e.Message.ToString() + "\"}");
     }
 }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int    Id    = Convert.ToInt32(Request.QueryString["Id"]);
            string g_url = Request.QueryString["g"];

            if (g_url != null)
            {
                string g_client = Mydb.ExecuteScalar("select GUID from CLIENT where CLIENT_ID=@Id", new SqlParameter[] { new SqlParameter("@Id", Id) }, CommandType.Text).ToString();
                if (g_client != g_url)
                {
                    Response.Redirect("Client_Admin/AlertingError.aspx?reason=g&chp=notC");
                }
                else
                {
                    //Mydb.ExecuteNoNQuery("update CLIENT set VERIFICATION_=1 where CLIENT_ID=@Id", new SqlParameter[] { new SqlParameter("@Id", Id) }, CommandType.Text);
                }
            }
        }
Exemplo n.º 12
0
        public static string Logtenant(string Score, int ObjId, string Room_Num, string PassT)
        {
            string result = "";
            //DataTable dt = Mydb.ExecuteReadertoDataTable("uspo_TenantLogin", new SqlParameter[] {new SqlParameter("@Score",Score),new SqlParameter("@ObjId", ObjId),new SqlParameter("@Room_Num", Room_Num) }, CommandType.StoredProcedure);
            //foreach (DataRow item in dt.Rows)
            //{
            //    result= "{\"result\" : \"" + item["Result"] + "\"}";
            //}
            int RoomCount = (int)Mydb.ExecuteScalar("select COUNT (*) from ROOM where ROOM_NUMBER=@Room_Num and ROOM_ID=(select ROOM_ID from PER_SCORE where SCORE_ID=@Score and OBJECT_ID=@ObjId)", new SqlParameter[] { new SqlParameter("@Room_Num", Room_Num), new SqlParameter("@Score", Score), new SqlParameter("@ObjId", ObjId) }, CommandType.Text);

            if (RoomCount != 0)
            {
                int PassCount = (int)Mydb.ExecuteScalar("select COUNT(*) from PER_SCORE where  PASS=@PassT and SCORE_ID=@Score and OBJECT_ID=@ObjId and ROOM_ID=(select ROOM_ID from ROOM where ROOM_NUMBER=@Room_Num and OBJECT_ID=@obj_Id)", new SqlParameter[] { new SqlParameter("@PassT", PassT), new SqlParameter("@Score", Score), new SqlParameter("@ObjId", ObjId), new SqlParameter("@Room_Num", Room_Num), new SqlParameter("@obj_Id", ObjId) }, CommandType.Text);

                if (PassCount == 1)
                {
                    int ProjectId = (int)Mydb.ExecuteScalar("select PROJECT_ID from OBJECT where OBJECT_ID=@ObjId", new SqlParameter[] { new SqlParameter("@ObjId", ObjId) }, CommandType.Text);

                    result = "{\"result\" : \"1\",\"objId\":\"" + ObjId + "\",\"C_Score\":\"" + Score + "\",\"ProjectId\":\"" + ProjectId + "\"}";  //"{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + Id + "\",\"RoleId\":\"" + role + "\"}";
                    //  result = @"{result:1,objId:" + ObjId + ",C_Score:" + Score + ",ProjectDatas:" + ProjectDatas + "}";
                }
                else
                {
                    int ProjectId = (int)Mydb.ExecuteScalar("select PROJECT_ID from OBJECT where OBJECT_ID=@ObjId", new SqlParameter[] { new SqlParameter("@ObjId", ObjId) }, CommandType.Text);

                    string LoginBitrix = Mydb.ExecuteReadertoDataTableAsJson("usp_CHECK_BITRIX_USER", new SqlParameter[] { new SqlParameter("@login", Score), new SqlParameter("@pwd", PassT) }, CommandType.StoredProcedure);
                    // dynamic jsonSets = JsonConvert.DeserializeObject(sets);
                    dynamic jsonLoginBitrix = JsonConvert.DeserializeObject(LoginBitrix);
                    if (jsonLoginBitrix[0].LOTUS_GUID != "Login failed")
                    {
                        result = "{\"result\" : \"1\",\"objId\":\"" + ObjId + "\",\"C_Score\":\"" + Score + "\",\"ProjectId\":\"" + ProjectId + "\"}";
                    }
                    else
                    {
                        result = "{\"result\" : \"0\"}";
                    }
                }
            }
            else
            {
                result = "{\"result\" : \"0\"}";
            }
            return(result);
        }
 public static string CheckMail(string mail_)
 {
     try
     {
         int CountOfMail = (int)Mydb.ExecuteScalar("select count(*) from ACCOUNT WHERE E_MAIL=@m", new SqlParameter[] { new SqlParameter("@m", mail_) }, CommandType.Text);
         if (CountOfMail > 0)
         {
             return("{\"result\" : \"1\"}");
         }
         else// if (CountOfMail==0)
         {
             return("{\"result\" : \"2\"}");
         }
     }
     catch (Exception e)
     {
         return("{\" ERROR\" : \"" + e.Message.ToString() + "\"}");
     }
 }
Exemplo n.º 14
0
        public static string GetObjAdr(string Pth)
        {
            int            ObjId = (int)Mydb.ExecuteScalar("GetObjId", new SqlParameter[] { new SqlParameter("@pth", Pth) }, CommandType.StoredProcedure);
            DataTable      dt    = Mydb.ExecuteReadertoDataTable("select o.OBJECT_ADRESS,o.OBJECT_NAME, (a.ACCOUNT_NAME + '  >  '+a.PHONE_NUMBER+'  >  '+a.E_MAIL) as Acc from OBJECT o, ACCOUNT a where o.OBJECT_ID=@oid and o.LOG_IN_ID=a.LOG_IN_ID", new SqlParameter[] { new SqlParameter("@oid", ObjId) }, CommandType.Text);
            List <ObjectS> objs  = new List <ObjectS>();

            foreach (DataRow item in dt.Rows)
            {
                ObjectS obj = new ObjectS();
                obj.ObjectAdress  = item["OBJECT_ADRESS"].ToString();
                obj.ObjectPhoto   = item["OBJECT_NAME"].ToString();
                obj.KladrObjectId = item["Acc"].ToString();
                obj.Object_Id     = ObjId;


                objs.Add(obj);
            }
            JavaScriptSerializer js = new JavaScriptSerializer();

            return(js.Serialize(objs));
        }
        public static string CheckAttandEmail(string mail, int TipOrg)
        {
            try
            {
                mail = "%" + mail + "%";

                int result = (int)Mydb.ExecuteScalar("select COUNT(*) from ACCOUNT where E_MAIL like @mail and CLIENT_ID=(select CLIENT_ID from CLIENT where ATTRIBUTE_ID=(select ATTRIBUTE_ID from CLIENT_ATTRIBUTE where ATTRIBUTE_ID=@org))", new SqlParameter[] { new SqlParameter("@mail", mail), new SqlParameter("@org", TipOrg) }, CommandType.Text);
                if (result == 1)
                {
                    return("{\" result\" : \"1\"}");
                }
                else
                {
                    return("{\" result\" : \"0\"}");
                }
            }
            catch (SqlException e)
            {
                return("{\" ERROR\" : \"" + e.Message.ToString() + "\"}");
            }
        }
Exemplo n.º 16
0
        public static string SaveRequest(string score, int indId, string Phone, List <ProductService_> prs, List <REQUEST_COMMENT> Cf, string RC, int ObjId, string comDate, string CFtime, string CTtime)
        {
            string result      = "";
            int    ObDispCount = (int)Mydb.ExecuteScalar("select COUNT(*) from DISP_OBJECT where OBJECT_ID=@o", new SqlParameter[] { new SqlParameter("@o", ObjId) }, CommandType.Text);

            // int ObDispCount = 1;
            if (ObDispCount != 0)
            {
                if (indId != 0)
                {
                    int RoomT = (int)Mydb.ExecuteScalar("select ROOM_TYPE_ID from ROOM where ROOM_ID=(select ROOM_ID from PER_SCORE where SCORE_ID =(select SCORE_ID from INDIVIDUAL_PERSCORE where INDIVIDUAL_ID=@indId))", new SqlParameter[] { new SqlParameter("@indId", indId) }, CommandType.Text);


                    Mydb.ExecuteNoNQuery("insert into REQUEST (INDIVIDUAL_ID,CR_DATE,STATUS_ID,ROOM_T,NUMBER,COMFORDATE,COM_TIME_FROM,COM_TIME_TO)values(@indId,GETDATE(),2,@roomT,@score,CAST(@Comdate as date),CAST(REPLACE(@CFtime,'-',':')as time(0) ),CAST(REPLACE(@CTtime,'-',':')as time(0)))", new SqlParameter[] {
                        new SqlParameter("@indId", indId),
                        new SqlParameter("@roomT", RoomT),
                        new SqlParameter("@score", score),
                        new SqlParameter("@Comdate", comDate),
                        new SqlParameter("@CFtime", CFtime),
                        new SqlParameter("@CTtime", CTtime)
                    }, CommandType.Text);
                }
                else
                {
                    string[] splited = Phone.Split('|');
                    Mydb.ExecuteNoNQuery("insert into IND_NAME (FIRST_NAME,PHONE) values(@f,@p)", new SqlParameter[] { new SqlParameter("@f", splited[1]), new SqlParameter("@p", splited[0]) }, CommandType.Text);

                    int LastIndId = (int)Mydb.ExecuteScalar("select top 1 INDIVIDUAL_ID from IND_NAME order by INDIVIDUAL_ID desc", new SqlParameter[] { }, CommandType.Text);

                    Mydb.ExecuteNoNQuery("insert into INDIVIDUAL_PERSCORE (INDIVIDUAL_ID,SCORE_ID) values(@i,@s)", new SqlParameter[] { new SqlParameter("@i", LastIndId), new SqlParameter("@s", score) }, CommandType.Text);

                    int RoomT = (int)Mydb.ExecuteScalar("select ROOM_TYPE_ID from ROOM where ROOM_ID=(select ROOM_ID from PER_SCORE where SCORE_ID =(select SCORE_ID from INDIVIDUAL_PERSCORE where INDIVIDUAL_ID=@indId))", new SqlParameter[] { new SqlParameter("@indId", LastIndId) }, CommandType.Text);

                    Mydb.ExecuteNoNQuery("insert into REQUEST (INDIVIDUAL_ID,CR_DATE,STATUS_ID,ROOM_T,NUMBER,COMFORDATE,COM_TIME_FROM,COM_TIME_TO)values(@indId,GETDATE(),2,@roomT,@score,CAST(@Comdate as date),CAST(REPLACE(@CFtime,'-',':')as time(0) ),CAST(REPLACE(@CTtime,'-',':')as time(0)))", new SqlParameter[] {
                        new SqlParameter("@indId", LastIndId),
                        new SqlParameter("@roomT", RoomT),
                        new SqlParameter("@score", score),
                        new SqlParameter("@Comdate", comDate),
                        new SqlParameter("@CFtime", CFtime),
                        new SqlParameter("@CTtime", CTtime)
                    }, CommandType.Text);
                }
                int LastReqId = (int)Mydb.ExecuteScalar("select top 1 REQUEST_ID from REQUEST order by REQUEST_ID desc", new SqlParameter[] { }, CommandType.Text);
                foreach (ProductService_ item in prs)
                {
                    Mydb.ExecuteNoNQuery("insert into REQUEST_SERVICE (REQUEST_ID,P_SERVICE_ID,QUANTITY,COST) values (@Rid,@PId,@Q,@C)", new SqlParameter[] {
                        new SqlParameter("@Rid", LastReqId),
                        new SqlParameter("@PId", item.SERVICE_ID),
                        new SqlParameter("@Q", item.QUANTITY),
                        new SqlParameter("@C", item.COST)
                    }, CommandType.Text);
                }
                Mydb.ExecuteNoNQuery("insert into REQUEST_COMMENT(REQUEST_COMMENT,REQUEST_ID) values(@RC,@Rid)", new SqlParameter[] {
                    new SqlParameter("@Rc", RC),
                    new SqlParameter("@Rid", LastReqId)
                    //,new SqlParameter("@Cf",Cf)
                }, CommandType.Text);
                foreach (REQUEST_COMMENT item in Cf)
                {
                    if (item.COMMENT_FILE != "0")
                    {
                        Mydb.ExecuteNoNQuery("insert into REQUEST_COMMENT (H_COMMNET_FILE,REQUEST_ID) values (@Cf,@Rid)", new SqlParameter[] { new SqlParameter("@Cf", item.COMMENT_FILE), new SqlParameter("@Rid", LastReqId) }, CommandType.Text);
                    }
                }
                //Mydb.ExecuteNoNQuery("update IND_NAME set PHONE=@p where INDIVIDUAL_ID=@i", new SqlParameter[] { new SqlParameter("@p", Phone),new SqlParameter("@i",indId) }, CommandType.Text);
                result = "{\"result\" : \"ok\"}";
            }
            else
            {
                result = "{\"result\" : \"no\"}";
            }
            return(result);
        }
        public static string LoginSystem(string email_, string pass_)
        {
            #region BadKod
            //if (!email_.Contains("Login_"))
            //{
            //    int Cpass_Mail = (int)Mydb.ExecuteScalar("select COUNT(PASSWORD ) FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text);
            //    if (Cpass_Mail > 0)
            //    {
            //        string pass_mail = Mydb.ExecuteScalar("select PASSWORD FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();
            //        bool verf = (bool)Mydb.ExecuteScalar("select VERIFICATION_ from CLIENT where CLIENT_ID=(select CLIENT_ID from ACCOUNT where E_MAIL=@mail)", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text);

            //        if (verf == true)
            //        {
            //            pass_ = GetMd5HashData(pass_);
            //            if (pass_mail == pass_)
            //            {
            //                string Client_Id = Mydb.ExecuteScalar("select CLIENT_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();

            //                string loginId = Mydb.ExecuteScalar("select LOG_IN_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();
            //                return "{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + loginId + "\"}";
            //            }
            //            else
            //            {
            //                return "{\"result\" : \"2\"}";
            //            }
            //        }
            //        else
            //        {
            //            return "{\"result\" : \"3\"}";
            //        }
            //    }
            //    else
            //    {
            //        return "{\"result\" : \"2\"}";
            //    }

            //}
            //else
            //{
            //    int Count_DBPass = (int)Mydb.ExecuteScalar("select count(PASSWORD) from ACCOUNT where LOGIN = @lg", new SqlParameter[] { new SqlParameter("@lg", email_) }, CommandType.Text);
            //    if (Count_DBPass > 0)
            //    {
            //        string DBPass = Mydb.ExecuteScalar("select PASSWORD from ACCOUNT where LOGIN = @lg", new SqlParameter[] { new SqlParameter("@lg", email_) }, CommandType.Text).ToString();

            //        pass_ = GetMd5HashData(pass_);
            //        if (pass_ == DBPass)
            //        {
            //            int LogId = (int)Mydb.ExecuteScalar("select LOG_IN_ID, PASSWORD from ACCOUNT where LOGIN=@lg", new SqlParameter[] { new SqlParameter("@lg", email_) }, CommandType.Text);
            //            DataTable dt = Mydb.ExecuteReadertoDataTable("select * from ACCOUNT_ROLE where LOG_IN_ID=@lgId", new SqlParameter[] { new SqlParameter("@lgId", LogId) }, CommandType.Text);
            //            List<MR> mrs = new List<MR>();
            //            foreach (DataRow item in dt.Rows)
            //            {
            //                MR mr = new MR();
            //                mr.sm = Mydb.ExecuteScalar("select MODUL_ID from MODUL_ROLE where MR_ID=@mr", new SqlParameter[] { new SqlParameter("@mr", Convert.ToInt32(item["MR_ID"])) }, CommandType.Text).ToString();
            //                mr.sr = Mydb.ExecuteScalar("select ROLE_ID from MODUL_ROLE where MR_ID=@mr", new SqlParameter[] { new SqlParameter("@mr", Convert.ToInt32(item["MR_ID"])) }, CommandType.Text).ToString();
            //                mrs.Add(mr);
            //            }
            //            JavaScriptSerializer js = new JavaScriptSerializer();
            //            return js.Serialize(mrs);
            //        }
            //        else
            //        {
            //            return "{\"result\" : \"2\"}";
            //        }
            //    }
            //    else
            //    {
            //        return "{\"result\" : \"2\"}";
            //    }

            //}
            #endregion

            string returnvalue    = null;
            string SUPPLIER_EMAIL = email_;
            if (!email_.Contains("Login_"))
            {
                int Cpass_Mail = (int)Mydb.ExecuteScalar("select COUNT(PASSWORD ) FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text);
                if (Cpass_Mail > 0)
                {
                    string pass_mail = Mydb.ExecuteScalar("select PASSWORD FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();
                    bool   verf      = (bool)Mydb.ExecuteScalar("select VERIFICATION_ from CLIENT where CLIENT_ID=(select CLIENT_ID from ACCOUNT where E_MAIL=@mail)", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text);
                    if (verf == true)
                    {
                        pass_ = GetMd5HashData(pass_);
                        if (pass_mail == pass_)
                        {
                            string Client_Id = Mydb.ExecuteScalar("select CLIENT_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();               //4

                            string loginId = Mydb.ExecuteScalar("select LOG_IN_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();                 //5
                            int    count   = (int)Mydb.ExecuteScalar("select COUNT(*) from ACCOUNT_ROLE where LOG_IN_ID =@lg", new SqlParameter[] { new SqlParameter("@lg", Convert.ToInt32(loginId)) }, CommandType.Text); //2
                            if (count == 1)
                            {
                                string role      = Mydb.ExecuteScalar("select ROLE_ID from MODUL_ROLE where MR_ID=(select MR_ID from ACCOUNT_ROLE where LOG_IN_ID =@lg)", new SqlParameter[] { new SqlParameter("@lg", Convert.ToInt32(loginId)) }, CommandType.Text).ToString();//3
                                string RolName   = "Нечего";
                                string ModulName = "Нечего";
                                if (role == "4")
                                {
                                    ModulName = "Клиентское администрирование";
                                    RolName   = "Администратор";
                                }
                                if (role == "3")
                                {
                                    ModulName = "Диспетчерская";
                                    RolName   = "Диспетчер";
                                }
                                if (role == "1")
                                {
                                    ModulName = "Личный кабинет";
                                    RolName   = "Управляющий";
                                }
                                Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                                    new SqlParameter("@EVENT_TYPE", "Вход"),
                                    new SqlParameter("@EVENT_STATUS", "Систем"),
                                    new SqlParameter("@EVENT_ROLE", RolName),
                                    new SqlParameter("@EVENT_MODULE", ModulName),
                                    new SqlParameter("@EVENT_MESSAGE", "Пользователь  вошел в систему"),
                                    new SqlParameter("@EVENT_MAKER", loginId)
                                }, CommandType.StoredProcedure);
                                returnvalue = "{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + loginId + "\",\"RoleId\":\"" + role + "\"}";
                            }
                            if (count > 1)
                            {
                                DataTable         dt  = Mydb.ExecuteReadertoDataTable("select ROLE_ID from MODUL_ROLE where MR_ID in (select MR_ID from ACCOUNT_ROLE where LOG_IN_ID =@lg)", new SqlParameter[] { new SqlParameter("@lg", Convert.ToInt32(loginId)) }, CommandType.Text);
                                List <LoginDatas> lds = new List <LoginDatas>();
                                foreach (DataRow item in dt.Rows)
                                {
                                    LoginDatas ld = new LoginDatas();
                                    ld.ROLE_ID = item["ROLE_ID"].ToString();
                                    ld.Id      = Client_Id;
                                    ld.LogId   = loginId;
                                    ld.result  = "5";
                                    lds.Add(ld);
                                }
                                JavaScriptSerializer js = new JavaScriptSerializer();
                                //returnvalue= "{\"result\" : \"5\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + loginId + "\",\"Roles\":\"" + js.Serialize(rls) + "\"}";
                                returnvalue = js.Serialize(lds);
                            }
                        }
                        else
                        {
                            returnvalue = "{\"result\" : \"2\"}";
                        }
                    }
                    else
                    {
                        returnvalue = "{\"result\" : \"3\"}";
                    }
                }
                else
                {
                    // returnvalue= "{\"result\" : \"2\"}";
                    string RESULT = Mydb.ExecuteScalar("CHECK_SUPPLIER", new SqlParameter[] { new SqlParameter("@email", email_), new SqlParameter("@pass", pass_) }, CommandType.StoredProcedure).ToString();
                    returnvalue = RESULT;
                }
            }
            else
            {
                int IdCount = (int)Mydb.ExecuteScalar("select Count(*) from ACCOUNT where [LOGIN]=@login", new SqlParameter[] { new SqlParameter("@login", email_) }, CommandType.Text);//Convert.ToInt32(email_);
                if (IdCount != 0)
                {
                    // email_ = email_.Substring(email_.LastIndexOf('_') + 1);
                    int Id           = (int)Mydb.ExecuteScalar("select LOG_IN_ID from ACCOUNT where [LOGIN]=@login", new SqlParameter[] { new SqlParameter("@login", email_) }, CommandType.Text);//Convert.ToInt32(email_);//5
                    int Count_DBPass = (int)Mydb.ExecuteScalar("select count(PASSWORD) from ACCOUNT where LOG_IN_ID=@id", new SqlParameter[] { new SqlParameter("@id", Id) }, CommandType.Text);
                    if (Count_DBPass > 0)
                    {
                        string DBPass = Mydb.ExecuteScalar("select PASSWORD from ACCOUNT where LOG_IN_ID = @lg", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text).ToString();
                        pass_ = GetMd5HashData(pass_);
                        if (pass_ == DBPass)
                        {
                            if (SUPPLIER_EMAIL != "Login_742")
                            {
                                string Client_Id = Mydb.ExecuteScalar("select CLIENT_ID FROM ACCOUNT WHERE LOG_IN_ID=@lg", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text).ToString();//1

                                //string loginId = Mydb.ExecuteScalar("select LOG_IN_ID FROM ACCOUNT WHERE E_MAIL=@mail", new SqlParameter[] { new SqlParameter("@mail", email_) }, CommandType.Text).ToString();
                                int count = (int)Mydb.ExecuteScalar("select COUNT(*) from ACCOUNT_ROLE where LOG_IN_ID =@lg", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text);//2
                                if (count == 1)
                                {
                                    string role      = Mydb.ExecuteScalar("select ROLE_ID from MODUL_ROLE where MR_ID=(select MR_ID from ACCOUNT_ROLE where LOG_IN_ID =@lg)", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text).ToString();//3
                                    string RolName   = "Нечего";
                                    string ModulName = "Нечего";
                                    if (role == "4")
                                    {
                                        ModulName = "Клиентское администрирование";
                                        RolName   = "Администратор";
                                    }
                                    if (role == "3")
                                    {
                                        ModulName = "Диспетчерская";
                                        RolName   = "Диспетчер";
                                    }
                                    if (role == "1")
                                    {
                                        ModulName = "Личный кабинет";
                                        RolName   = "Управляющий";
                                    }
                                    if (role == "15")
                                    {
                                        ModulName = "Диспетчерская";
                                        RolName   = "Диспетчер поставщика";
                                    }
                                    if (role == "17")
                                    {
                                        ModulName = "Диспетчерская";
                                        RolName   = "Супер Диспетчер";
                                    }

                                    if (role == "16")
                                    {
                                        ModulName = "Профиль Управляющего";
                                        RolName   = "Ответственный";
                                    }
                                    Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                                        new SqlParameter("@EVENT_TYPE", "Вход"),
                                        new SqlParameter("@EVENT_STATUS", "Систем"),
                                        new SqlParameter("@EVENT_ROLE", RolName),
                                        new SqlParameter("@EVENT_MODULE", ModulName),
                                        new SqlParameter("@EVENT_MESSAGE", "Пользователь вошел в систему"),
                                        new SqlParameter("@EVENT_MAKER", Id)
                                    }, CommandType.StoredProcedure);
                                    returnvalue = "{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + Id + "\",\"RoleId\":\"" + role + "\"}";
                                }
                                if (count > 1)
                                {
                                    DataTable         dt  = Mydb.ExecuteReadertoDataTable("select ROLE_ID from MODUL_ROLE where MR_ID in (select MR_ID from ACCOUNT_ROLE where LOG_IN_ID =@lg)", new SqlParameter[] { new SqlParameter("@lg", Id) }, CommandType.Text);//3
                                    List <LoginDatas> lds = new List <LoginDatas>();
                                    foreach (DataRow item in dt.Rows)
                                    {
                                        LoginDatas ld = new LoginDatas();
                                        ld.ROLE_ID = item["ROLE_ID"].ToString();
                                        ld.Id      = Client_Id;
                                        ld.LogId   = Id.ToString();
                                        ld.result  = "5";
                                        lds.Add(ld);
                                    }
                                    JavaScriptSerializer js = new JavaScriptSerializer();
                                    //returnvalue= "{\"result\" : \"5\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + loginId + "\",\"Roles\":\"" + js.Serialize(rls) + "\"}";
                                    returnvalue = js.Serialize(lds);
                                    //List<Roles> rls = new List<Roles>();
                                    //foreach (DataRow item in dt.Rows)
                                    //{
                                    //    Roles rl = new Roles();
                                    //    rl.ROLE_ID = Convert.ToInt32(item["ROLE_ID"]);
                                    //    rls.Add(rl);
                                    //}
                                    //JavaScriptSerializer js = new JavaScriptSerializer();
                                    //returnvalue= "{\"result\" : \"5\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + Id + "\",\"Roles\":\"" + js.Serialize(rls) + "\"}";
                                }
                            }
                            else
                            {
                                string role      = "15";
                                string RolName   = "Нечего";
                                string ModulName = "Нечего";

                                if (role == "15")
                                {
                                    ModulName = "Диспетчер поставщика";
                                    RolName   = "Диспетчер поставщика";
                                }
                                Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                                    new SqlParameter("@EVENT_TYPE", "Вход"),
                                    new SqlParameter("@EVENT_STATUS", "Систем"),
                                    new SqlParameter("@EVENT_ROLE", RolName),
                                    new SqlParameter("@EVENT_MODULE", ModulName),
                                    new SqlParameter("@EVENT_MESSAGE", "Пользователь вошел в систему"),
                                    new SqlParameter("@EVENT_MAKER", Id)
                                }, CommandType.StoredProcedure);
                                returnvalue = "{\"result\" : \"1\",\"Id\" :\"742\",\"LogId\" :\"" + Id + "\",\"RoleId\":\"" + role + "\"}";
                            }
                        }
                        else
                        {
                            returnvalue = "{\"result\" : \"2\"}";
                        }
                    }
                    else
                    {
                        returnvalue = "{\"result\" : \"2\"}";
                    }
                }
                else
                {
                    returnvalue = "{\"result\" : \"2\"}";
                }
            }
            return(returnvalue);
        }
        private static string UK_Login(string Id_)
        {
            int    Id          = 0;
            string returnvalue = "";

            if (Id_.Contains('@'))
            {
                Id = Convert.ToInt32(Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "5"), new SqlParameter("@mail", Id_) }, CommandType.StoredProcedure));
            }
            else
            {
                Id_ = Id_.Substring(Id_.IndexOf('_') + 1);
                Id  = Convert.ToInt32(Id_);
            }
            string Client_Id = Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@lg", Id), new SqlParameter("@procType", "1") }, CommandType.StoredProcedure).ToString();//1


            int count = (int)Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "2"), new SqlParameter("@lg", Id) }, CommandType.StoredProcedure);//2

            if (count == 1)
            {
                string role      = Mydb.ExecuteScalar("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "3"), new SqlParameter("@lg", Id) }, CommandType.StoredProcedure).ToString();//3
                string RolName   = "Нечего";
                string ModulName = "Нечего";
                if (role == "4")
                {
                    ModulName = "Клиентское администрирование";
                    RolName   = "Администратор";
                }
                if (role == "3")
                {
                    ModulName = "Диспетчерская";
                    RolName   = "Диспетчер";
                }
                if (role == "1")
                {
                    ModulName = "Личный кабинет";
                    RolName   = "Управляющий";
                }
                if (role == "15")
                {
                    ModulName = "Диспетчерская";
                    RolName   = "Диспетчер поставщика";
                }
                if (role == "17")
                {
                    ModulName = "Диспетчерская";
                    RolName   = "Супер Диспетчер";
                }

                if (role == "16")
                {
                    ModulName = "Профиль Управляющего";
                    RolName   = "Ответственный";
                }
                Mydb.ExecuteNoNQuery("usp_ConstructorAPI_INSERT_LOG", new SqlParameter[] {
                    new SqlParameter("@EVENT_TYPE", "Вход"),
                    new SqlParameter("@EVENT_STATUS", "Систем"),
                    new SqlParameter("@EVENT_ROLE", RolName),
                    new SqlParameter("@EVENT_MODULE", ModulName),
                    new SqlParameter("@EVENT_MESSAGE", "Пользователь вошел в систему"),
                    new SqlParameter("@EVENT_MAKER", Id)
                }, CommandType.StoredProcedure);
                returnvalue = "{\"result\" : \"1\",\"Id\" :\"" + Client_Id + "\",\"LogId\" :\"" + Id + "\",\"RoleId\":\"" + role + "\"}";
            }
            if (count > 1)
            {
                DataTable         dt  = Mydb.ExecuteReadertoDataTable("LoginIdendity", new SqlParameter[] { new SqlParameter("@procType", "3"), new SqlParameter("@lg", Id) }, CommandType.StoredProcedure);//3
                List <LoginDatas> lds = new List <LoginDatas>();
                foreach (DataRow item in dt.Rows)
                {
                    LoginDatas ld = new LoginDatas();
                    ld.ROLE_ID = item["ROLE_ID"].ToString();
                    ld.Id      = Client_Id;
                    ld.LogId   = Id.ToString();
                    ld.result  = "5";
                    lds.Add(ld);
                }
                JavaScriptSerializer js = new JavaScriptSerializer();

                returnvalue = js.Serialize(lds);
            }
            return(returnvalue);
        }
Exemplo n.º 19
0
        public static void COMPARE_REQUESTS(bool is_Compare, string Request_as_JSON, int R_id_guid, int lg, string EVENT_MESSAGE, string path, string R_Services)
        {
            string R_id_guid2 = R_id_guid.ToString();
            int    REQUEST_ID = 0;

            if (int.TryParse(R_id_guid2, out REQUEST_ID))
            {
            }
            string EVENT_TYPE;
            string EVENT_STATUS = "Важное";
            //  string path = HttpContext.Current.Request.Url.AbsolutePath;

            string EVENT_ROLE = (path.IndexOf("Manager/") > -1) ? "Управляющий" : (path.IndexOf("Super_Disp/") > -1) ? "Супер Диспетчер" : (path.IndexOf("Responsible_Admin/") > -1) ? "Ответственный" : (path.IndexOf("Disp_Admin/") > -1) ? "Диспетчер" : "Диспетчер поставщика";

            string EVENT_MODULE = (path.IndexOf("Manager/") > -1) ? "Профиль Управляющего" : (path.IndexOf("Super_Disp/") > -1) ? "Диспетчерская" : (path.IndexOf("Responsible_Admin/") > -1) ? "Профиль Управляющего" : (path.IndexOf("Disp_Admin/") > -1) ? "Диспетчерская" : "Диспетчер поставщика";

            if (is_Compare == false)
            {
                if (REQUEST_ID != 0)
                {
                    EVENT_TYPE = "Создан";
                    ExecuteNoNQuery("[usp_ConstructorAPI_INSERT_LOG]", new SqlParameter[] {
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@EVENT_STATUS", EVENT_STATUS),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_MODULE", EVENT_MODULE),
                        new SqlParameter("@EVENT_MESSAGE", EVENT_MESSAGE),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@JSON_DATAS", Request_as_JSON)
                    }, CommandType.StoredProcedure);
                    if (Request_as_JSON != "4" && Request_as_JSON != "5")
                    {
                        Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewUkR"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);

                        Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewResp"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);

                        Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewIspol"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);
                    }
                }
                else
                {
                    Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewSuppR"), new SqlParameter("@rGuid", R_id_guid2), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);
                }
            }
            else
            {
                EVENT_TYPE = "Обновить";

                ExecuteNoNQuery("[usp_ConstructorAPI_INSERT_LOG]", new SqlParameter[] {
                    new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                    new SqlParameter("@EVENT_STATUS", EVENT_STATUS),
                    new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                    new SqlParameter("@EVENT_MODULE", EVENT_MODULE),
                    new SqlParameter("@EVENT_MESSAGE", EVENT_MESSAGE),
                    new SqlParameter("@EVENT_MAKER", lg),
                    new SqlParameter("@REQUEST_ID", REQUEST_ID),
                    new SqlParameter("@JSON_DATAS", Request_as_JSON)
                }, CommandType.StoredProcedure);

                dynamic Old_requests = JsonConvert.DeserializeObject(ExecuteAsJson("GETRequestForLOG", new SqlParameter[] { new SqlParameter("@rid", REQUEST_ID) }, CommandType.StoredProcedure));

                dynamic newRequest      = JsonConvert.DeserializeObject(Request_as_JSON);
                int     STATUS_ID       = (int)newRequest[0].STATUS_ID;
                string  TextForPlanDate = "";
                string  TextForPlanTime = "";
                //if (REQUEST_ID != 0)
                //{
                //    Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewStatus"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@NewStatusId", STATUS_ID) }, CommandType.StoredProcedure);
                //}
                //else
                //{
                //    Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "NewUkRStatus"), new SqlParameter("@rGuid", R_id_guid2), new SqlParameter("@NewStatusId", STATUS_ID) }, CommandType.StoredProcedure);
                //}
                string   Pdate     = newRequest[0].Pdate;
                string[] charArray = Pdate.Split('-');

                Pdate = charArray[2] + "." + charArray[1] + '.' + charArray[0];

                string PLAN_END_DATE = Old_requests[0].PLAN_END_DATE;


                PLAN_END_DATE = (PLAN_END_DATE.Length != 0) ? PLAN_END_DATE.Substring(0, 10) : "";

                if (Pdate != PLAN_END_DATE && PLAN_END_DATE.Length != 0)
                {
                    TextForPlanDate = ": планируемая дата изменена с «" + PLAN_END_DATE + "» на «" + Pdate + "»";
                    ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@LOG_TYPE", 1),
                        new SqlParameter("@PLAN_DATE_TEXT", TextForPlanDate)
                    }, CommandType.StoredProcedure);
                }
                else
                {
                    if (PLAN_END_DATE.Length == 0)
                    {
                        TextForPlanDate = ": Выбран планируемая дата на «" + Pdate + "»";
                        ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                            new SqlParameter("@REQUEST_ID", REQUEST_ID),
                            new SqlParameter("@EVENT_MAKER", lg),
                            new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                            new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                            new SqlParameter("@LOG_TYPE", 1),
                            new SqlParameter("@PLAN_DATE_TEXT", TextForPlanDate)
                        }, CommandType.StoredProcedure);
                    }
                }
                string Ptime         = newRequest[0].Ptime;
                string PLAN_END_TIME = Old_requests[0].PLAN_END_TIME;
                PLAN_END_TIME = (PLAN_END_TIME.Length != 0) ? PLAN_END_TIME.Substring(0, 5) : "";
                Ptime         = Ptime.Substring(0, 5);
                if (Ptime != PLAN_END_TIME && PLAN_END_TIME.Length != 0)
                {
                    TextForPlanTime = ": планируемое время изменено с «" + PLAN_END_TIME + "» на «" + Ptime + "»";

                    ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@LOG_TYPE", 1),
                        new SqlParameter("@PLAN_DATE_TEXT", TextForPlanTime)
                    }, CommandType.StoredProcedure);
                }
                else
                {
                    if (PLAN_END_TIME.Length == 0)
                    {
                        TextForPlanTime = ": Выбран планируемое время  на «" + Ptime + "»";

                        ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                            new SqlParameter("@REQUEST_ID", REQUEST_ID),
                            new SqlParameter("@EVENT_MAKER", lg),
                            new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                            new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                            new SqlParameter("@LOG_TYPE", 1),
                            new SqlParameter("@PLAN_DATE_TEXT", TextForPlanTime)
                        }, CommandType.StoredProcedure);
                    }
                }


                //  string TextForPerformer = "";
                string newspId = Convert.ToString(newRequest[0].spId);
                Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "IspolChange"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@IspolId", newspId), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);
                string OldSPECIALIS_ID = Convert.ToString(Old_requests[0].SPECIALIS_ID);
                if (newspId != OldSPECIALIS_ID)
                {
                    var new_spId = (newRequest[0].spId != null) ? Convert.ToInt32(newRequest[0].spId) : DBNull.Value;

                    var Old_SPECIALIS_ID = (Old_requests[0].SPECIALIS_ID != DBNull.Value) ? Convert.ToInt32(Old_requests[0].SPECIALIS_ID) : DBNull.Value;
                    // TextForPerformer = "исполнитель изменен с «" + Old_requests.SPECIALIS_ID + "» на «" + newRequest.spId + "»";
                    ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@LOG_TYPE", 2),
                        new SqlParameter("@OLD_ID", Old_SPECIALIS_ID),
                        new SqlParameter("@NEW_ID", new_spId)
                    }, CommandType.StoredProcedure);
                }

                //  string TextForResponsible = "";
                string newResp = Convert.ToString(newRequest[0].RESPONSIBLE_ID);
                Mydb.ExecuteNoNQuery("LoginForRequest", new SqlParameter[] { new SqlParameter("@action", "RespChange"), new SqlParameter("@rId", REQUEST_ID), new SqlParameter("@RespId", newResp), new SqlParameter("@lg", lg) }, CommandType.StoredProcedure);
                string oldResp = Convert.ToString(Old_requests[0].RESPONSIBLE_ID);
                if (newResp != oldResp)
                {
                    //TextForResponsible = "ответственный по заявке изменен с «" + Old_requests.RESPONSIBLE_ID + "» на «" + newRequest.RESPONSIBLE_ID + "»";
                    var New_RESPONSIBLE_ID = (newRequest[0].RESPONSIBLE_ID != null) ? Convert.ToInt32(newRequest[0].RESPONSIBLE_ID) : DBNull.Value;
                    var Old_RESPONSIBLE_ID = (Old_requests[0].RESPONSIBLE_ID != DBNull.Value) ? Convert.ToInt32(Old_requests[0].RESPONSIBLE_ID) : DBNull.Value;

                    ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                        new SqlParameter("@REQUEST_ID", REQUEST_ID),
                        new SqlParameter("@EVENT_MAKER", lg),
                        new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                        new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                        new SqlParameter("@LOG_TYPE", 3),
                        new SqlParameter("@OLD_ID", Old_RESPONSIBLE_ID),
                        new SqlParameter("@NEW_ID", New_RESPONSIBLE_ID)
                    }, CommandType.StoredProcedure);
                }

                dynamic New_prs = JsonConvert.DeserializeObject(R_Services);
                dynamic Old_prs = JsonConvert.DeserializeObject(ExecuteAsJson("GETREQUEST_SERVICES_FOR_LOG", new SqlParameter[] { new SqlParameter("@REQUEST_ID", REQUEST_ID) }, CommandType.StoredProcedure));

                //Если Добавлена услуга или Группа услуг или изиеннено

                for (int k = 0; k < New_prs.Count; k++)
                {
                    string New_Service_Guid = Convert.ToString(New_prs[k].SERVICE_GUID);
                    object New_ParentId     = ExecuteScalar("GetParentIdOfServices", new SqlParameter[] { new SqlParameter("@SERVICE_GUID", New_Service_Guid) }, CommandType.StoredProcedure);
                    int    CountOf_Service  = (int)Mydb.ExecuteScalar("GetServiceCount", new SqlParameter[] { new SqlParameter("@rid", REQUEST_ID), new SqlParameter("@service_gud", New_Service_Guid) }, CommandType.StoredProcedure);
                    //  Если Добавлена услуга
                    if (New_ParentId != DBNull.Value)
                    {
                        if (CountOf_Service == 0)
                        {
                            string NEW_quantity2 = Convert.ToString(New_prs[k].QUANTITY);

                            ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                new SqlParameter("@EVENT_MAKER", lg),

                                new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                new SqlParameter("@LOG_TYPE", 5),
                                new SqlParameter("@NEW_QUANTITY", NEW_quantity2),
                                new SqlParameter("@SERVICE_GUID", Convert.ToString(New_prs[k].SERVICE_GUID))
                            }, CommandType.StoredProcedure);
                        }
                        //изменено данные старых услуг
                        else
                        {
                            dynamic old          = JsonConvert.DeserializeObject(Mydb.ExecuteAsJson("GetService_COST_QUANTITY", new SqlParameter[] { new SqlParameter("@SERVICE_GUID", New_Service_Guid), new SqlParameter("@rid", REQUEST_ID) }, CommandType.StoredProcedure));
                            string  OLD_quantity = Convert.ToString(old[0].QUANTITY);
                            string  OLD_cost     = Convert.ToString(old[0].COST);

                            string NEW_COST = Convert.ToString(New_prs[k].COST);

                            string NEW_quantity = Convert.ToString(New_prs[k].QUANTITY);
                            NEW_quantity = (NEW_quantity.IndexOf('.') != -1) ? NEW_quantity.Replace(".", ",") : NEW_quantity + ",00";
                            if (OLD_cost != NEW_COST)
                            {
                                ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                    new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                    new SqlParameter("@EVENT_MAKER", lg),
                                    new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                    new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                    new SqlParameter("@LOG_TYPE", 4),
                                    new SqlParameter("@OLD_COST", (OLD_cost == "0.00")?"Договорная":OLD_cost),
                                    new SqlParameter("@NEW_COST", (NEW_COST == "0.00")?"Договорная":NEW_COST),
                                    new SqlParameter("@SERVICE_GUID", Convert.ToString(New_prs[k].SERVICE_GUID))
                                }, CommandType.StoredProcedure);
                            }
                            if (OLD_quantity != NEW_quantity)
                            {
                                ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                    new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                    new SqlParameter("@EVENT_MAKER", lg),
                                    new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                    new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                    new SqlParameter("@LOG_TYPE", 4),
                                    new SqlParameter("@OLD_QUANTITY", OLD_quantity),
                                    new SqlParameter("@NEW_QUANTITY", NEW_quantity),
                                    new SqlParameter("@SERVICE_GUID", Convert.ToString(New_prs[k].SERVICE_GUID))
                                }, CommandType.StoredProcedure);
                            }
                        }
                    }
                    // Если Добавлена Группа услуг
                    else
                    {
                        int Count_Grups = (int)Mydb.ExecuteScalar("GetServiceCount", new SqlParameter[] { new SqlParameter("@rid", REQUEST_ID), new SqlParameter("@Parent", "yes") }, CommandType.StoredProcedure);
                        if (Count_Grups == 0)
                        {
                            string NEW_quantity2 = Convert.ToString(New_prs[k].QUANTITY);

                            ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                new SqlParameter("@EVENT_MAKER", lg),
                                new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                new SqlParameter("@LOG_TYPE", 5),
                                new SqlParameter("@NEW_QUANTITY", NEW_quantity2),
                                new SqlParameter("@SERVICE_GUID", Convert.ToString(New_prs[k].SERVICE_GUID))
                            }, CommandType.StoredProcedure);
                        }
                        else
                        {
                            // если старый Группа услуг изменено на новый
                            string Old_Service_Guid = Mydb.ExecuteScalar("GetGrupOf_service_ofRequest", new SqlParameter[] { new SqlParameter("@rid", REQUEST_ID) }, CommandType.StoredProcedure).ToString();
                            if (Old_Service_Guid != New_Service_Guid)
                            {
                                ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                    new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                    new SqlParameter("@EVENT_MAKER", lg),
                                    new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                    new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                    new SqlParameter("@LOG_TYPE", 7),
                                    new SqlParameter("@Old_Service_guid", Old_Service_Guid),
                                    new SqlParameter("@New_Service_guid", New_Service_Guid)
                                }, CommandType.StoredProcedure);
                            }
                        }
                    }
                }

                //если Удалено услуги
                for (int i = 0; i < Old_prs.Count; i++)
                {
                    string Old_Service_Guid = Convert.ToString(Old_prs[i].SERVICE_GUID);
                    object Old_ParentId     = ExecuteScalar("GetParentIdOfServices", new SqlParameter[] { new SqlParameter("@SERVICE_GUID", Old_Service_Guid) }, CommandType.StoredProcedure);
                    if (Old_ParentId != DBNull.Value)
                    {
                        bool hasService = false;

                        for (int k = 0; k < New_prs.Count; k++)
                        {
                            string New_Service_Guid = Convert.ToString(New_prs[k].SERVICE_GUID);
                            if (New_Service_Guid == Old_Service_Guid)
                            {
                                hasService = true;
                            }
                        }
                        if (hasService == false)
                        {
                            ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                new SqlParameter("@EVENT_MAKER", lg),
                                new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                new SqlParameter("@LOG_TYPE", 6),
                                new SqlParameter("@OLD_QUANTITY", "0"),
                                new SqlParameter("@SERVICE_GUID", Old_Service_Guid)
                            }, CommandType.StoredProcedure);
                        }
                    }
                    else
                    {
                        bool IsDeletedOrNot = false;
                        for (int k = 0; k < New_prs.Count; k++)
                        {
                            string New_Service_Guid = Convert.ToString(New_prs[k].SERVICE_GUID);
                            object New_ParentId     = ExecuteScalar("GetParentIdOfServices", new SqlParameter[] { new SqlParameter("@SERVICE_GUID", New_Service_Guid) }, CommandType.StoredProcedure);
                            if (New_ParentId != DBNull.Value)
                            {
                                IsDeletedOrNot = true;
                            }
                        }
                        if (IsDeletedOrNot == true)
                        {
                            ExecuteNoNQuery("[insert_HISTORY_LOG]", new SqlParameter[] {
                                new SqlParameter("@REQUEST_ID", REQUEST_ID),
                                new SqlParameter("@EVENT_MAKER", lg),
                                new SqlParameter("@EVENT_ROLE", EVENT_ROLE),
                                new SqlParameter("@EVENT_TYPE", EVENT_TYPE),
                                new SqlParameter("@LOG_TYPE", 6),
                                new SqlParameter("@OLD_QUANTITY", "0"),
                                new SqlParameter("@SERVICE_GUID", Old_Service_Guid)
                            }, CommandType.StoredProcedure);
                        }
                    }
                }
            }
        }