Exemplo n.º 1
0
        public ActionResult Table(string id = "")
        {
            if (! String.IsNullOrWhiteSpace(id))
            {
                string last_update = (from u in this._db.recsys_users
                                      orderby u.last_update descending
                                      select u.last_update).FirstOrDefault().ToString();
                return Content(String.IsNullOrWhiteSpace(last_update) ? "null" : last_update);
            }
            else
            {
                Grid _grid = new Grid();
                String sql = _grid.sql("users");
                ArrayList table = Common.query(this._db.ExecuteStoreQuery<recsys_users>(sql));
                Hashtable result = _grid.get(table);
                if (((ArrayList)result["rows"]).Count > 0)
                {
                    Hashtable type = this.getType();
                    Hashtable user_group = this.getUserGroup();
                    Hashtable country = this.getCountry();
                    Dictionary<string, string> grade = this.getGrade();
                    ArrayList sort = new ArrayList();
                    string path = Server.MapPath("~/") + "/";

                    string subContractor_userGroup_name = UserGroup.SubCon;
                    string subContractor_id = (from o in this._db.recsys_option
                                                      where o.type_code == "UG" && o.active == true && o.name == subContractor_userGroup_name
                                                      select o.value).FirstOrDefault();

                    foreach (Hashtable rs in (ArrayList)result["rows"])
                    {
                        Hashtable hash = new Hashtable();
                        string filePath = "Upload/users/" + rs["id"] + "/photo/";
                        string realPath = path + filePath;
                        ArrayList filelist = Common.fileList(realPath, filePath);

                        Boolean subcon = rs["user_group"].ToString() == subContractor_id;
                        object user_group_id = rs["user_group"];
                        object user_group_name = user_group_id != null ? user_group[user_group_id.ToString()] : string.Empty;
                        object grade_name = rs["grade"] != null ? grade[rs["grade"].ToString()] : string.Empty;
                        object country_id = rs["country_id"];
                        object country_name = country_id != null ? country[country_id.ToString()] : string.Empty;
                        hash["id"] = rs["id"];
                        hash["cell"] = new ArrayList {
                            rs["id"],
                            rs["name"],
                            type[rs["type_id"].ToString()],
                            subcon ? "--" : type[rs["type_id"].ToString()],
                            user_group_name,
                            rs["center"],
                            subcon ? "--" : rs["center"],
                            grade_name,
                            grade_name,
                            rs["employee_number"],
                            rs["username"],
                            subcon ? "--" : rs["username"],
                            "",
                            "",
                            "",
                            country_name,
                            country_name,
                            rs["phone_number"],
                            rs["email"],
                            (filelist.Count > 0 ? "<img src=\"/img.ashx?width=53&height=53&bg=ffffff&file=" + ((String[]) filelist[0])[0] + "\" alt=\"" + ((String[]) filelist[0])[1] + "\" style=\"border: 1px solid #d4d4d4;\" />" : ""),
                            "<span class=\"status-" + (Convert.ToInt32(rs["status"]) == 1 ? "on" : "off") + "\" title=\"" + this._status[rs["status"].ToString()] + "\"></span>",
                            this._status[rs["status"].ToString()],
                            Common.to_date("dd-MM-yyyy hh:mm:ss", rs["create_date"]),
                            Common.lastUpdate(rs["last_update"], rs["update_user_id"])
                        };
                        sort.Add(hash);
                    }
                    result["rows"] = sort;
                }
                return Content(Common.json_encode(result));
            }
        }
 public ActionResult Items_Template(string id = "")
 {
     if (!String.IsNullOrWhiteSpace(id))
     {
         string last_update = (from it in this._db.recsys_quotation_items_template
                               orderby it.last_update descending
                               select it.last_update).FirstOrDefault().ToString();
         return Content(String.IsNullOrWhiteSpace(last_update) ? "null" : last_update);
     }
     else
     {
         Grid _grid = new Grid();
         String sql = _grid.sql("quotation_items_template");
         ArrayList table = Common.query(this._db.ExecuteStoreQuery<recsys_quotation_items_template>(sql));
         Hashtable result = _grid.get(table);
         if (((ArrayList)result["rows"]).Count > 0)
         {
             ArrayList sort = new ArrayList();
             foreach (Hashtable rs in (ArrayList)result["rows"])
             {
                 Hashtable hash = new Hashtable();
                 hash["id"] = rs["id"];
                 hash["cell"] = new ArrayList {
                     rs["id"],
                     rs["code"],
                     rs["detail"],
                     rs["detail2"],
                     rs["price"],
                     Common.lastUpdate(rs["last_update"], rs["update_user_id"])
                 };
                 sort.Add(hash);
             }
             result["rows"] = sort;
         }
         return Content(Common.json_encode(result));
     }
 }
Exemplo n.º 3
0
 public ActionResult Table(string id = "")
 {
     if (!String.IsNullOrWhiteSpace(id))
     {
         string last_update = (from s in this._db.recsys_supplier
                               orderby s.last_update descending
                               select s.last_update).FirstOrDefault().ToString();
         return Content(String.IsNullOrWhiteSpace(last_update) ? "null" : last_update);
     }
     else
     {
         Grid _grid = new Grid();
         String sql = _grid.sql("supplier");
         ArrayList table = Common.query(this._db.ExecuteStoreQuery<recsys_supplier>(sql));
         Hashtable result = _grid.get(table);
         if (((ArrayList)result["rows"]).Count > 0)
         {
             ArrayList sort = new ArrayList();
             foreach (Hashtable rs in (ArrayList)result["rows"])
             {
                 Hashtable hash = new Hashtable();
                 hash["id"] = rs["id"];
                 hash["cell"] = new ArrayList {
                     rs["id"],
                     rs["name"],
                     "<span class=\"status-" + (Convert.ToInt32(rs["status"]) == 1 ? "on" : "off") + "\" title=\"" + this._status[rs["status"].ToString()] + "\"></span>",
                     this._status[rs["status"].ToString()],
                     Common.lastUpdate(rs["last_update"], rs["update_user_id"])
                 };
                 sort.Add(hash);
             }
             result["rows"] = sort;
         }
         return Content(Common.json_encode(result));
     }
 }
Exemplo n.º 4
0
 public ActionResult Jobs(string id = "")
 {
     string order_id = Common.doPost("order_id");
     if (!String.IsNullOrWhiteSpace(id))
     {
         String sql = Common.doSql("SELECT j.last_update FROM {p}_job AS j LEFT JOIN {p}_relate AS r ON r.id2 = j.id WHERE r.table1 = 'order' AND r.table2 = 'job' AND r.id1 = '" + order_id + "' ORDER BY j.last_update DESC");
         string last_update = this._db.ExecuteStoreQuery<DateTime>(sql).FirstOrDefault().ToString();
         return Content(String.IsNullOrWhiteSpace(last_update) ? "null" : last_update);
     }
     else
     {
         Grid _grid = new Grid();
         String sql = Common.doSql(_grid.sql("", "SELECT j.* FROM {p}_job AS j LEFT JOIN {p}_relate AS r ON r.id2 = j.id WHERE r.table1 = 'order' AND r.table2 = 'job' AND r.id1 = '" + order_id + "'"));
         ArrayList table = Common.query(this._db.ExecuteStoreQuery<recsys_job>(sql));
         Hashtable result = _grid.get(table);
         if (((ArrayList)result["rows"]).Count > 0)
         {
             ArrayList sort = new ArrayList();
             foreach (Hashtable rs in (ArrayList)result["rows"])
             {
                 Hashtable hash = new Hashtable();
                 hash["id"] = rs["id"];
                 hash["cell"] = new ArrayList {
                     rs["id"],
                     rs["detail1"],
                     rs["detail2"],
                     Common.lastUpdate(rs["last_update"], rs["update_user_id"])
                 };
                 sort.Add(hash);
             }
             result["rows"] = sort;
         }
         return Content(Common.json_encode(result));
     }
 }
Exemplo n.º 5
0
 public ActionResult Parts_Table(string id = "")
 {
     int order_id = Convert.ToInt32(Common.doPost("order_id"));
     if (!String.IsNullOrWhiteSpace(id))
     {
         String sql = Common.doSql("SELECT p.last_update FROM {p}_parts AS p LEFT JOIN {p}_relate AS r ON r.id1 = p.id WHERE r.table1 = 'parts' AND r.table2 = 'order' AND r.id2 = '" + order_id + "' ORDER BY p.last_update DESC");
         string last_update = this._db.ExecuteStoreQuery<DateTime>(sql).FirstOrDefault().ToString();
         return Content(String.IsNullOrWhiteSpace(last_update) ? "null" : last_update);
     }
     else
     {
         Grid _grid = new Grid();
         String sql = Common.doSql(_grid.sql("", "SELECT p.*, s.name as supplier_name FROM {p}_parts AS p LEFT JOIN {p}_supplier AS s ON p.supplier_id = s.id LEFT JOIN {p}_relate AS r ON r.id1 = p.id", "r.table1 = 'parts' AND r.table2 = 'order' AND r.id2 = '" + order_id + "'"));
         ArrayList table = Common.query(this._db.ExecuteStoreQuery<parts>(sql));
         Hashtable result = _grid.get(table);
         if (((ArrayList)result["rows"]).Count > 0)
         {
             ArrayList sort = new ArrayList();
             foreach (Hashtable rs in (ArrayList)result["rows"])
             {
                 Hashtable hash = new Hashtable();
                 hash["id"] = rs["id"];
                 hash["cell"] = new ArrayList {
                     rs["id"],
                     rs["name"],
                     rs["invoice"],
                     rs["price1"],
                     rs["price2"],
                     rs["detail"],
                     rs["supplier_name"],
                     rs["supplier_id"],
                     Common.to_date("dd-MM-yyyy", rs["account_date"]),
                     Common.to_date("dd-MM-yyyy", rs["account_date"]),
                     "<span class=\"status-" + (Convert.ToInt32(rs["status"]) == 1 ? "on" : "off") + "\" title=\"" + this._status[rs["status"].ToString()] + "\"></span>",
                     this._status[rs["status"].ToString()],
                     rs["remark"],
                     Common.lastUpdate(rs["last_update"], rs["update_user_id"])
                 };
                 sort.Add(hash);
             }
             result["rows"] = sort;
         }
         return Content(Common.json_encode(result));
     }
 }
Exemplo n.º 6
0
 public ActionResult Table(string id = "")
 {
     if (!String.IsNullOrWhiteSpace(id))
     {
         string last_update = (from g in this._db.recsys_group
                               orderby g.last_update descending
                               select g.last_update).FirstOrDefault().ToString();
         return Content(String.IsNullOrWhiteSpace(last_update) ? "null" : last_update);
     }
     else
     {
         Grid _grid = new Grid();
         String sql = Common.doSql(_grid.sql("", "SELECT g.* FROM {p}_group AS g LEFT JOIN {p}_users AS u ON g.supervisor_id = u.id"));
         ArrayList table = Common.query(this._db.ExecuteStoreQuery<recsys_group>(sql));
         Hashtable result = _grid.get(table);
         if (((ArrayList)result["rows"]).Count > 0)
         {
             Member _member = new Member("users");
             ArrayList sort = new ArrayList();
             foreach (Hashtable rs in (ArrayList)result["rows"])
             {
                 sql = Common.doSql("SELECT u.* FROM {p}_relate AS r LEFT JOIN {p}_users AS u ON r.id2 = u.id WHERE r.id1 = '" + rs["id"] + "' AND r.table1 = 'group' AND r.table2 = 'users' ORDER BY u.name ASC");
                 ArrayList engineer = Common.query(this._db.ExecuteStoreQuery<recsys_users>(sql));
                 ArrayList arr1 = new ArrayList();
                 ArrayList arr2 = new ArrayList();
                 Hashtable supervisor = _member.get(rs["supervisor_id"].ToString(), "id");
                 if (engineer.Count > 0)
                 {
                     foreach (Hashtable item in engineer)
                     {
                         arr1.Add(item["name"]);
                         arr2.Add(item["id"]);
                     }
                 }
                 Hashtable hash = new Hashtable();
                 hash["id"] = rs["id"];
                 hash["cell"] = new ArrayList {
                     rs["id"],
                     rs["name"],
                     supervisor["name"],
                     rs["supervisor_id"],
                     string.Join(", ", arr1.ToArray()),
                     string.Join(",", arr2.ToArray()),
                     "<span class=\"status-" + (Convert.ToInt32(rs["status"]) == 1 ? "on" : "off") + "\" title=\"" + this._status[rs["status"].ToString()] + "\"></span>",
                     this._status[rs["status"].ToString()],
                     Common.lastUpdate(rs["last_update"], rs["update_user_id"])
                 };
                 sort.Add(hash);
             }
             result["rows"] = sort;
         }
         return Content(Common.json_encode(result));
     }
 }