Beispiel #1
0
        public HttpResponseMessage SavePRData(PRHeaderModels Header)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            int id = repository.InsertHeader(Header, ref errMsg);

            //ds.Tables.Add(dtDocumentVnos);
            if (errMsg != "" && errMsg != "ยอดรวมมากกว่างบประมาณอนุมัติของแผนกในเดือนปัจจุบัน")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #2
0
        public HttpResponseMessage GETGeneratePRID(int id)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            DataTable dtDocumentVnos = repository.GeneratePONo(id, ref errMsg);

            ds.Tables.Add(dtDocumentVnos);
            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #3
0
        public HttpResponseMessage CancelPRTmpDetail(int id)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();

            repository.DeleteTmpDetail(id, ref errMsg);



            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #4
0
        public HttpResponseMessage GETDashBroadByDepartment(int id)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            ds = Reportrepository.GetDashBroadByDepartment(id, ref errMsg);


            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #5
0
        public HttpResponseMessage GETListReportBudget(int year, int month, int StaffCode, int DEPcode)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            DataTable dtHeaderData = Reportrepository.GetReportBudget(year, month, StaffCode, DEPcode, ref errMsg);

            ds.Tables.Add(dtHeaderData);

            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #6
0
        public HttpResponseMessage GETReportPR(DateTime startdate, DateTime finishdate, int dep, int status)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            DataTable dtHeaderData = Reportrepository.GetPRReport(startdate, finishdate, dep, status, ref errMsg);

            ds.Tables.Add(dtHeaderData);

            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #7
0
        public HttpResponseMessage GETListPROverForApprove(int id, int depid)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();

            dt = repository.GetPROverDataForApprove(id, depid, ref errMsg);


            ds.Tables.Add(dt);

            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
        private VKParams GetSearchParams(
            String query,
            Boolean autoComplete,
            Boolean lyrics,
            Boolean performerOnly,
            VKSearchSortEnum sort,
            Boolean searchOwn,
            Int32 offset,
            Int32?count)
        {
            VKParams param = new VKParams();

            param.Add("q", query);
            param.Add("auto_complete", autoComplete.ToVKValue());
            param.Add("lyrics", lyrics.ToVKValue());
            param.Add("performer_only", performerOnly.ToVKValue());
            param.Add("sort", EnumString.GetStringValue(sort));
            param.Add("search_own", searchOwn.ToVKValue());
            param.Add("offset", offset);
            if (count.HasValue)
            {
                param.Add("count", count);
            }

            return(param);
        }
Beispiel #9
0
        public HttpResponseMessage GETPrepareReportPR()
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            dt = Reportrepository.GetDEP();
            ds.Tables.Add(dt);
            DataTable dtstatus = Reportrepository.GetPRStatus();

            ds.Tables.Add(dtstatus);
            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #10
0
        public HttpResponseMessage UpdateDetailData(PRDetailModels detail, int id)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            int docid = repository.UpdatetmpDetail(detail, ref errMsg);

            //ds.Tables.Add(dtDocumentVnos);
            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
        public HttpResponseMessage GETStaffRoleDataByID(int POSid)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();

            dt = repository.GetPermissionDataByID(ref errMsg, POSid);

            //dt = repository.GetDepartmentData(ref errMsg);

            ds.Tables.Add(dt);

            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            resData.Records = ds.Tables[0].Rows.Count;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #12
0
        public HttpResponseMessage UpdatePreviewDetailData(List <PRDetailModels> detail)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();

            //foreach (PRDetailModels item in detail) {
            //    item.Document_Detail_Hid = id;

            //}

            repository.UpdatePreviewDetail(detail, ref errMsg);

            //ds.Tables.Add(dtDocumentVnos);
            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #13
0
        public HttpResponseMessage GETViewPO(int id, int StaffID)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            DataTable dtHeaderData = repository.GetPOHeaderData(id, StaffID, ref errMsg);


            DataTable dtDetail = repository.GetDetailData(id, ref errMsg);


            ds.Tables.Add(dtHeaderData);
            ds.Tables.Add(dtDetail);

            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
        public async Task <HttpResponseMessage> GetBudgetByDep(int id)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();

            dt = await repository.GetBudgetByDep(id);

            ds.Tables.Add(dt);

            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            resData.Records = ds.Tables[0].Rows.Count;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
        public HttpResponseMessage PostLogin(StaffModels item)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();

            dt = repository.Login(item.StaffLogin, item.StaffPassword, ref errMsg);

            ds.Tables.Add(dt);
            if (dt.Rows.Count <= 0 && errMsg == "")
            {
                errMsg = "รหัสพนักงาน/รหัสผ่าน ไม่ถูกต้อง." + Environment.NewLine + "โปรดตรวจสอบ รหัสพนักงาน/รหัสผ่าน ก่อน login เข้าระบบอีกครั้ง";
            }
            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            resData.Records = ds.Tables[0].Rows.Count;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #16
0
        public HttpResponseMessage RejectPOData(PRHeaderModels Header)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();


            int id = repository.RejectPO(Header.Document_Id, Header.Document_CreateUser, ref errMsg);

            //ds.Tables.Add(dtDocumentVnos);
            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #17
0
        public HttpResponseMessage PostLogPreview(int id)
        {
            string    errMsg   = "";
            bool      ret      = false;
            DataSet   ds       = new DataSet();
            DataTable dt       = new DataTable();
            Result    response = new Result();



            repository.LogPreview(id, ref errMsg);
            if (errMsg != "")
            {
                response.StatusCode = (int)(StatusCodes.Error);
                response.Messages   = errMsg;
            }
            else
            {
                response.StatusCode = (int)(StatusCodes.Succuss);
                response.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }



            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Beispiel #18
0
        public HttpResponseMessage updateFileEdit(List <string> listfiledelete, int docid, string tmpupload)
        {
            Result resData = new Result();

            try
            {
                //string path = HttpContext.Current.Server.MapPath("~/Upload/" + Pathfile);

                foreach (string item in listfiledelete)
                {
                    string sourcePath = System.Web.Hosting.HostingEnvironment.MapPath("~/Upload/" + item);
                    if (System.IO.File.Exists(sourcePath))
                    {
                        System.IO.File.Delete(sourcePath);
                    }
                }
                string Path       = System.Web.Hosting.HostingEnvironment.MapPath("~/tmpUpload/" + tmpupload + "/");
                string targetpath = System.Web.Hosting.HostingEnvironment.MapPath("~/Upload/" + docid.ToString() + "/");
                if (System.IO.Directory.Exists(Path))
                {
                    if (!System.IO.Directory.Exists(targetpath))
                    {
                        System.IO.Directory.CreateDirectory(targetpath);
                    }

                    string[] files = System.IO.Directory.GetFiles(Path);

                    // Copy the files and overwrite destination files if they already exist.
                    foreach (string s in files)
                    {
                        // Use static Path methods to extract only the file name from the path.
                        string fileName = System.IO.Path.GetFileName(s);
                        string destFile = System.IO.Path.Combine(targetpath, fileName);
                        System.IO.File.Copy(s, destFile, true);
                    }
                    System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(Path);
                    foreach (System.IO.FileInfo file in di.GetFiles())
                    {
                        file.Delete();
                    }
                    foreach (System.IO.DirectoryInfo dir in di.GetDirectories())
                    {
                        dir.Delete(true);
                    }
                }


                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }
            catch (Exception ex)
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = ex.Message;;
            }

            //Send OK Response to Client.
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
        private VKParams GetBroadcastParams(VKBroadcastFilterEnum filter, Boolean getOnlyActive)
        {
            VKParams param = new VKParams();

            param.Add("active", getOnlyActive.ToVKValue());
            param.Add("filter", EnumString.GetStringValue(filter));

            return(param);
        }
Beispiel #20
0
        /// <summary>
        /// The to string.
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public override string ToString()
        {
            string stateRoverPosition = string.Format(
                "{0}{1}{2}",
                this.RoverPosition.X,
                this.RoverPosition.Y,
                EnumString.GetStringValue(this.RoverCompass));

            return(stateRoverPosition);
        }
Beispiel #21
0
        /// <summary>
        /// The state rover position.
        /// </summary>
        private void StateRoverPosition()
        {
            string stateRoverPosition = string.Format(
                " X : {0}  Y : {1}  Direction : {2}",
                this.RoverPosition.X,
                this.RoverPosition.Y,
                EnumString.GetStringValue(this.RoverCompass));

            Console.WriteLine(stateRoverPosition);
        }
        public async Task <HttpResponseMessage> GetNotiPO(int id)
        {
            Result resData = new Result();

            int po = await repository.GetListPOForApprove(id);

            resData.StatusCode = (int)(StatusCodes.Succuss);
            resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);

            resData.Results = po;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #23
0
        public HttpResponseMessage GetFileUpload(int id)
        {
            string    errMsg  = "";
            DataSet   ds      = new DataSet();
            DataTable dt      = new DataTable();
            Result    resData = new Result();
            //Get Pathfile
            DataTable dtfile = new DataTable();

            dtfile.Columns.Add("filename");
            dtfile.Columns.Add("path");


            string targetpath = System.Web.Hosting.HostingEnvironment.MapPath("~/Upload/" + id.ToString() + "/");

            if (System.IO.Directory.Exists(targetpath))
            {
                string[] files = System.IO.Directory.GetFiles(targetpath);

                // Copy the files and overwrite destination files if they already exist.
                foreach (string s in files)
                {
                    DataRow dr = dtfile.NewRow();



                    // Use static Path methods to extract only the file name from the path.
                    dr[0] = System.IO.Path.GetFileName(s);
                    dr[1] = id.ToString() + "/" + dr[0];

                    dtfile.Rows.Add(dr);
                    //string destFile = System.IO.Path.Combine(targetpath, fileName);
                }
            }
            dtfile.TableName = "FileUpload";
            ds.Tables.Add(dtfile);

            if (errMsg != "")
            {
                resData.StatusCode = (int)(StatusCodes.Error);
                resData.Messages   = errMsg;
            }
            else
            {
                resData.StatusCode = (int)(StatusCodes.Succuss);
                resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);
            }

            resData.Results = ds;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
        public async Task <HttpResponseMessage> GetNotiPreview(int id)
        {
            Result resData = new Result();

            int prview = await repository.GetListPreview(id);


            resData.StatusCode = (int)(StatusCodes.Succuss);
            resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);


            resData.Results = prview;
            //resData.Records = ds.Tables[0].Rows.Count;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }
Beispiel #25
0
        public String MySQLCompute()
        {
            String result = "";

            foreach (var item in links)
            {
                result += EnumString.GetStringValue(item.Value.First().Key) + " " + item.Key;
                if (item.Value.First().Value != null)
                {
                    result += " " + item.Value.First().Value.MySQLCompute();
                }
                result += " ";
            }

            return(result);
        }
        public MysqlDbContext(ConnectionResource connectionResource)
            : base(EnumString.GetStringValue(connectionResource))
        {
            switch (connectionResource)
            {
            case ConnectionResource.APIMYSQL:
                InitDatabaseAsync();
                break;

            case ConnectionResource.LOCALMYSQL:
                InitDatabaseAsync();
                break;

            default:
                break;
            }
        }
Beispiel #27
0
        public MySQLFullDB(DataConnectionResource dataConnectionResource)
            : base(EnumString.GetStringValue(dataConnectionResource))
        {
            switch (dataConnectionResource)
            {
            case DataConnectionResource.GENERICMYSQL:
                break;

            case DataConnectionResource.LOCALMYSQL:
                break;

            case DataConnectionResource.LOCALAPI:
                break;

            default:
                break;
            }
        }
Beispiel #28
0
        /// <summary>
        /// Does a request to the web service to test if it is available.
        /// </summary>
        public static void SetConnectionResource()
        {
            try
            {
                var webRequest = (HttpWebRequest)WebRequest.Create(EnumString.GetStringValue(ConnectionResource.LOCALAPI));
                var response   = (HttpWebResponse)webRequest.GetResponse();

                if (response.StatusCode == HttpStatusCode.OK) // Web service is up and running
                {
                    DataSource = ConnectionResource.LOCALAPI;
                    Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() =>
                    {
                        if (ConnectionStatus != null)
                        {
                            ConnectionStatus.Text = "Connected to : Web Service";
                        }
                    }));
                }
                else // Web service responded but might be broken
                {
                    DataSource = ConnectionResource.LOCALMYSQL;
                    Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() =>
                    {
                        if (ConnectionStatus != null)
                        {
                            ConnectionStatus.Text = "Connected to : Local Database";
                        }
                    }));
                }
            }
            catch (Exception e) // Web service is not available
            {
                DataSource = ConnectionResource.LOCALMYSQL;
                Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() =>
                {
                    if (ConnectionStatus != null)
                    {
                        ConnectionStatus.Text = "Connected to : Local Database";
                    }
                }));
            }
        }
Beispiel #29
0
        public String MySQLCompute()
        {
            String result = EnumString.GetStringValue(this.dbAction);

            result += " ";
            result += this.dbSelector;
            result += " ";
            result += this.dbTablesLinks.MySQLCompute();

            if (criterions.Count > 0)
            {
                result += "WHERE";
                result += " ";
            }

            foreach (var item in criterions)
            {
                result += item.MySQLCompute();
                result += " ";
            }
            return(result);
        }
        public async Task <HttpResponseMessage> GetNotiPR(int id)   //async Task<HttpResponseMessage>
        {
            Result resData = new Result();

            int prcount = await repository.GetPRforApprove(id);  //await

            //NotiData item = new NotiData();
            //item.index = 1;
            //if (prcount > 0)
            //{
            //    item.NotiText = "มี " + prcount + " รายการขออนุมัติงบประมาณรอการอนุมัติ'";
            //}
            //_noti.Add(item);
            //_hubcontext.Clients.All.NotiData("", _noti);

            resData.StatusCode = (int)(StatusCodes.Succuss);
            resData.Messages   = (String)EnumString.GetStringValue(StatusCodes.Succuss);

            resData.Results = prcount;
            //resData.Records = ds.Tables[0].Rows.Count;
            return(Request.CreateResponse(HttpStatusCode.OK, resData));
        }