Esempio n. 1
0
        public void DeleteRecord(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                CompanyRightToWork s = new CompanyRightToWork();
                s.recordId    = index;
                s.remarks     = "";
                s.documentRef = "";
                s.issueDate   = DateTime.Now;
                s.expiryDate  = DateTime.Now;
                s.dtId        = 0;
                s.dtName      = "";
                s.branchId    = 0;
                s.branchName  = "";



                PostRequest <CompanyRightToWork> req = new PostRequest <CompanyRightToWork>();
                req.entity = s;
                PostResponse <CompanyRightToWork> r = _systemService.ChildDelete <CompanyRightToWork>(req);
                if (!r.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(r);
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    Store1.Remove(index);

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
Esempio n. 2
0
        public void DeleteRecord(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                UserInfo s = new UserInfo();
                s.recordId    = index;
                s.accountId   = "";
                s.companyName = "";
                s.email       = "";
                s.fullName    = "";
                s.languageId  = 0;

                PostRequest <UserInfo> req = new PostRequest <UserInfo>();
                req.entity = s;
                PostResponse <UserInfo> r = _systemService.ChildDelete <UserInfo>(req);
                if (!r.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    Store1.Remove(index);

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
Esempio n. 3
0
        public void DeleteAttachment(string index, string path)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                Attachement n = new Attachement();
                n.classId  = ClassId.DMDO;
                n.recordId = 0;
                n.seqNo    = Convert.ToInt16(index);
                n.fileName = path;

                PostRequest <Attachement> req = new PostRequest <Attachement>();
                req.entity = n;
                PostResponse <Attachement> res = _systemService.ChildDelete <Attachement>(req);
                if (!res.Success)
                {
                    //Show an error saving...
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, res.Summary).Show();
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    Store1.Remove(index);

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
Esempio n. 4
0
        public void DeleteRecord(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database 
                LetterTemplate n = new LetterTemplate();
                n.recordId = index;
                n.name = "";
                PostRequest<LetterTemplate> req = new PostRequest<LetterTemplate>();
                req.entity = n;
                PostResponse<LetterTemplate> res = _systemService.ChildDelete<LetterTemplate>(req);
                if (!res.Success)
                {
                    //Show an error saving...
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, res.Summary).Show();
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    Store1.Remove(index);

                    //Step 3 : Showing a notification for the user 
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon = Icon.Information,
                        Html = Resources.Common.RecordDeletedSucc
                    });
                }

            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();

            }

        }
Esempio n. 5
0
        public void DeleteFile(string url, int id)
        {
            try
            {
                Attachement a = new Attachement();
                a.recordId = id;

                string[] line = url.Split('/');
                if (line.Length >= 7)
                {
                    a.classId  = ClassId.EPRW;
                    a.fileName = line[6];
                    string[] seq = line[6].Split('.');

                    string[] seq1 = seq[0].Split('-');
                    if (seq1.Length >= 2)
                    {
                        a.seqNo = Convert.ToInt16(seq1[1]);
                    }
                }

                PostRequest <Attachement> request = new PostRequest <Attachement>();

                request.entity = a;
                PostResponse <Attachement> r = _systemService.ChildDelete <Attachement>(request);

                if (!r.Success)//it maybe be another condition
                {
                    //Show an error saving...
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(r);
                    return;
                }
            }catch (Exception exp)
            {
                X.MessageBox.Alert(GetGlobalResourceObject("Common", "Error").ToString(), exp.Message);
            }
        }
Esempio n. 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/javascript";

            try
            {
                //write your handler implementation here.

                if (context.Request.Files.Count <= 0)
                {
                    PostRequest <Attachement> request = new PostRequest <Attachement>();

                    Attachement at = new Attachement();
                    at.classId  = ClassId.EPEM;
                    at.recordId = Convert.ToInt32(context.Request.QueryString["recordId"]);
                    at.seqNo    = 0;
                    at.folderId = null;

                    at.fileName    = context.Request.Form["oldUrl"];
                    request.entity = at;
                    PostResponse <Attachement> response = _systemService.ChildDelete <Attachement>(request);
                    if (response.Success)
                    {
                        context.Response.Write("{}");
                    }
                    else
                    {
                        context.Response.Write("{Error}");
                    }
                }
                else
                {
                    if (context.Request.QueryString["classId"].ToString() != ClassId.SYDE.ToString())
                    {
                        EmployeeUploadPhotoRequest upreq = new EmployeeUploadPhotoRequest();
                        upreq.entity.fileName = context.Request.Files[0].FileName;
                        byte[] fileData = null;
                        for (int i = 0; i < context.Request.Files.Count; ++i)
                        {
                            HttpPostedFile f = context.Request.Files.Get(i);
                            fileData = new byte[Convert.ToInt32(f.InputStream.Length)];
                            if (f.InputStream.Length > 1435405312)
                            {
                                context.Response.Write("{'Error':'largImage'}");
                                return;
                            }
                            f.InputStream.Seek(0, SeekOrigin.Begin);
                            f.InputStream.Read(fileData, 0, Convert.ToInt32(f.InputStream.Length));
                            f.InputStream.Close();

                            upreq.photoName       = context.Request.Files[0].FileName;
                            upreq.photoData       = fileData;
                            upreq.entity.recordId = Convert.ToInt32(context.Request.QueryString["recordId"]);
                            upreq.entity.date     = DateTime.Now;
                        }

                        PostResponse <Attachement> resp = _employeeService.UploadEmployeePhoto(upreq);
                        if (!resp.Success)
                        {
                            context.Response.Write("{'Error':'Error'}");
                            return;
                        }
                    }
                    else
                    {
                        byte[]         fileData = null;
                        HttpPostedFile f        = context.Request.Files.Get(0);
                        if (f.InputStream.Length > 0)
                        {
                            fileData = new byte[Convert.ToInt32(f.InputStream.Length)];
                            f.InputStream.Seek(0, SeekOrigin.Begin);
                            f.InputStream.Read(fileData, 0, Convert.ToInt32(f.InputStream.Length));
                            f.InputStream.Close();
                        }
                        else
                        {
                            fileData = null;
                        }



                        //check if the insert failed

                        if (fileData != null)
                        {
                            SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest();
                            if (context.Request.Files.Count == 1)
                            {
                                req.entity = new Model.System.Attachement()
                                {
                                    date = DateTime.Now, classId = ClassId.SYDE, recordId = 1, fileName = context.Request.Files[0].FileName, seqNo = 0
                                }
                            }
                            ;
                            else
                            {
                                req.entity = new Model.System.Attachement()
                                {
                                    date = DateTime.Now, classId = ClassId.SYDE, recordId = 1, fileName = context.Request.Files[0].FileName, seqNo = null
                                }
                            };
                            req.FileNames.Add(context.Request.Files[0].FileName);
                            req.FilesData.Add(fileData);
                            PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req);
                            if (!resp.Success)
                            {
                                context.Response.Write("{'Error':'Error'}");
                                return;
                            }
                        }
                    }
                }
                context.Response.Write("{}");
            }
            catch (Exception exp)
            {
                context.Response.Write("{'Error':'Error'}");
            }
        }
Esempio n. 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/javascript";

            if (context.Request.Files.Count <= 0)
            {
                PostRequest <Attachement> request = new PostRequest <Attachement>();

                Attachement at = new Attachement();
                at.classId  = ClassId.EPEM;
                at.recordId = Convert.ToInt32(context.Request.QueryString["recordId"]);
                at.seqNo    = 0;
                at.folderId = null;

                at.fileName    = context.Request.Form["oldUrl"];
                request.entity = at;
                PostResponse <Attachement> response = _systemService.ChildDelete <Attachement>(request);
                if (response.Success)
                {
                    context.Response.Write("{}");
                }
                else
                {
                    context.Response.Write("{Error}");
                }
            }
            SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest();

            if (ClassId.EPDO == Convert.ToInt32(context.Request.QueryString["classId"]))
            {
                req.entity = new Model.System.Attachement()
                {
                    date = DateTime.Now, classId = Convert.ToInt32(context.Request.QueryString["classId"]), recordId = Convert.ToInt32(context.Request.QueryString["recordId"]), fileName = Regex.Replace(context.Request.Files[0].FileName, @"[^0-9a-zA-Z.]+", ""), seqNo = null
                }
            }
            ;
            else
            {
                if (context.Request.Files.Count == 1)
                {
                    req.entity = new Model.System.Attachement()
                    {
                        date = DateTime.Now, classId = Convert.ToInt32(context.Request.QueryString["classId"]), recordId = Convert.ToInt32(context.Request.QueryString["recordId"]), fileName = Regex.Replace(context.Request.Files[0].FileName, @"[^0-9a-zA-Z.]+", ""), seqNo = 0
                    }
                }
                ;
                else
                {
                    req.entity = new Model.System.Attachement()
                    {
                        date = DateTime.Now, classId = Convert.ToInt32(context.Request.QueryString["classId"]), recordId = Convert.ToInt32(context.Request.QueryString["recordId"]), fileName = Regex.Replace(context.Request.Files[0].FileName, @"[^0-9a-zA-Z.]+", ""), seqNo = null
                    }
                };
            }
            //write your handler implementation here.
            int bulk;

            if (int.TryParse(context.Request.Form["id"], out bulk))
            {
                req.entity.folderId = bulk;
            }
            else
            {
                req.entity.folderId = null;
            }


            byte[] fileData = null;
            for (int i = 0; i < context.Request.Files.Count; ++i)
            {
                HttpPostedFile f = context.Request.Files.Get(i);
                fileData = new byte[Convert.ToInt32(f.InputStream.Length)];
                f.InputStream.Seek(0, SeekOrigin.Begin);
                f.InputStream.Read(fileData, 0, Convert.ToInt32(f.InputStream.Length));
                f.InputStream.Close();

                req.FilesData.Add((byte[])fileData.Clone());
                req.FileNames.Add(Regex.Replace(f.FileName, @"[^0-9a-zA-Z.]+", ""));
            }

            PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req);

            if (!resp.Success)
            {
                context.Response.Write("{'Error':'Error'}");
                return;
            }


            context.Response.Write("{}");
        }