示例#1
0
        public static string Update(Int32 FSID, FSStatusType fst, FSStatusType tst, String Comments)
        {
            string strSql;

            if (!Login.OnLineMode)
            {
                using (CEConn localDB = new CEConn())
                {
                    strSql = "Update FS_AssetStatus set FSStatus=" + Convert.ToInt32(fst) + ", TaskStatus =" + Convert.ToInt32(tst) + ", comments ='" + Comments + "', Date_Modified = getDate(), ModifiedBy =" + Login.ID + ", ID_Employee =" + Login.ID + ", RowStatus= " + Convert.ToInt32(RowStatus.Modify) + " where ID_FSAssetStatus=" + FSID;
                    localDB.runQuery(strSql);
                    return("");
                }
            }
            else
            {
                //Update FS_AssetStatus

                Synchronize.Synchronise OnConn = new Synchronize.Synchronise();
                OnConn.Url = Login.webURL;
                String result;
                result = OnConn.UpdateFS_AssetStatus1(FSID, Convert.ToInt32(fst), Convert.ToInt32(tst), Login.ID, DateTime.Now, Comments);

                return(result);
            }
        }
示例#2
0
        public static void AddEmployee(String TagID, String EmpNo, String UserName, String Password, Int32 RoleID)
        {
            if (!Login.OnLineMode)
            {
                Int32 Skey;
                Skey = minServerKey();
                // added by vijay 08 Dec 2009
                if (Skey == -2)
                {
                    Skey = Skey - 1;
                }

                bool tagAssigned = false;

                using (CEConn localDB = new CEConn())
                {
                    string strSql;


                    TagInfo Ti = new TagInfo(TagID);
                    if (Ti.isAssetTag() || Ti.isLocationTag() || Ti.isEmployeeTag())
                    {
                        tagAssigned = true;
                    }
                    else
                    {
                        tagAssigned = false;
                    }

                    //strSql = " select count(*) from Assets A,Employees E,Locations L where A.TagID='" + TagID + "' or E.TagID='" + TagID + "' or L.TagID='" + TagID + "'";
                    ////select count(*) from Locations where TagID='" + TagID + "'";
                    if (tagAssigned == true && !string.IsNullOrEmpty(TagID))
                    {
                        throw new ApplicationException("Duplicate Tag ID.");
                    }

                    strSql  = " insert into Employees(TagID,UserName,EmpNo,Password,Date_Modified,ID_SecurityGroup,ModifiedBy,RowStatus,serverKey)";
                    strSql += " values('" + TagID + "','" + UserName.Replace("'", "''") + "','" + EmpNo.Replace("'", "''") + "','" + Password.Replace("'", "''") + "',getDate()," + RoleID + "," + Login.ID + "," + Convert.ToInt32(RowStatus.New) + "," + Skey + ")";
                    localDB.runQuery(strSql);
                }
            }
            else
            {
                DataTable dtEmployee = new DataTable("dtEmployee");

                dtEmployee.Columns.Add("EmpNo", typeof(String));
                dtEmployee.Columns.Add("UserName", typeof(String));
                dtEmployee.Columns.Add("Password", typeof(String));
                dtEmployee.Columns.Add("TagID", typeof(String));
                dtEmployee.Columns.Add("ID_SecurityGroup", typeof(Int32));
                dtEmployee.Columns.Add("ModifiedBy", typeof(Int32));
                dtEmployee.AcceptChanges();

                DataRow dr;
                dr = dtEmployee.NewRow();

                dr["EmpNo"]            = EmpNo;
                dr["UserName"]         = UserName;
                dr["Password"]         = Password;
                dr["TagID"]            = TagID;
                dr["ID_SecurityGroup"] = RoleID;
                dr["ModifiedBy"]       = Login.ID;

                dtEmployee.Rows.Add(dr);
                dtEmployee.AcceptChanges();

                Synchronize.Synchronise OnConn = new Synchronize.Synchronise();
                OnConn.Url = Login.webURL;
                DataTable dtResult;
                dtResult = OnConn.AddEmployee(dtEmployee);

                if (dtResult.Rows.Count != 0)
                {
                    if (Convert.ToInt32(dtResult.Rows[0]["RowStatus"]) == Convert.ToInt32(RowStatus.Error))
                    {
                        throw new ApplicationException("Insert Failed.");
                    }
                    else
                    {
                        //Inserted Sucessfully
                    }
                }

                //throw new ApplicationException("Online functionality not implemented yet.");
            }
        }
示例#3
0
        public static void AddTaskPerformed(Int32 TaskID, Int32 EmployeeID, Int32 ItemId)
        {
            if (!Login.OnLineMode)
            {
                Int32 Skey;
                Skey = minServerKey();

                // added by vijay 08 Dec 2009
                if (Skey == -2)
                {
                    Skey = Skey - 1;
                }

                using (CEConn localDB = new CEConn())
                {
                    string strSql;
                    strSql  = " insert into PerformedTasks(ID_Tasks,ID_Employee,ID_Asset,Date_Modified,ModifiedBy,RowStatus,serverKey)";
                    strSql += " values(" + TaskID + "," + EmployeeID + "," + ItemId + ",getDate()," + EmployeeID + "," + Convert.ToInt32(RowStatus.New) + "," + Skey + ")";
                    localDB.runQuery(strSql);
                    if (taskPerformed != null)
                    {
                        taskPerformed(ItemId.ToString());
                    }
                }
            }
            else
            {
                DataTable dtPTask = new DataTable("dtPTask");

                dtPTask.Columns.Add("ID_Tasks", typeof(Int32));
                dtPTask.Columns.Add("ID_Employee", typeof(Int32));
                dtPTask.Columns.Add("ID_Asset", typeof(Int32));
                dtPTask.Columns.Add("Date_Modified", typeof(DateTime));
                dtPTask.Columns.Add("ModifiedBy", typeof(Int32));
                dtPTask.AcceptChanges();

                DataRow dr;
                dr = dtPTask.NewRow();

                dr["ID_Tasks"]      = TaskID;
                dr["ID_Employee"]   = EmployeeID;
                dr["ID_Asset"]      = ItemId;
                dr["Date_Modified"] = DateTime.Now;
                dr["ModifiedBy"]    = Login.ID;

                dtPTask.Rows.Add(dr);
                dtPTask.AcceptChanges();

                Synchronize.Synchronise OnConn = new Synchronize.Synchronise();
                OnConn.Url = Login.webURL;
                DataTable dtResult;
                dtResult = OnConn.AddPerformedTask(dtPTask);

                if (dtResult.Rows.Count != 0)
                {
                    if (Convert.ToInt32(dtResult.Rows[0]["RowStatus"]) == Convert.ToInt32(RowStatus.Error))
                    {
                        throw new ApplicationException("Insert Failed.");
                    }
                    else
                    {
                        if (taskPerformed != null)
                        {
                            taskPerformed(ItemId.ToString());
                        }
                        //Inserted Sucessfully
                    }
                }
                //throw new ApplicationException("Online functionality of Location not implemented yet.");
            }
        }
示例#4
0
        public static void AddLocation(String TagID, String LocationNo, String LocationName)
        {
            if (!Login.OnLineMode)
            {
                Int32 Skey;
                Skey = minServerKey();

                // added by vijay 08 Dec 2009
                if (Skey == -2)
                {
                    Skey = Skey - 1;
                }

                bool tagAssigned = false;

                using (CEConn localDB = new CEConn())
                {
                    string strSql;

                    if (TagID.Length > 0) // to allow blank tagid for locations 05-11-2011
                    {
                        TagInfo Ti = new TagInfo(TagID);
                        if (Ti.isAssetTag() || Ti.isLocationTag() || Ti.isEmployeeTag())
                        {
                            tagAssigned = true;
                        }
                        else
                        {
                            tagAssigned = false;
                        }

                        //strSql = " select count(*) from Assets A,Employees E,Locations L where A.TagID='" + TagID + "' or E.TagID='" + TagID + "' or L.TagID='" + TagID + "'";
                        ////select count(*) from Locations where TagID='" + TagID + "'";
                        if (tagAssigned == true)
                        {
                            throw new ApplicationException("Duplicate Tag ID.");
                        }
                    }


                    //strSql = " select count(*) from Assets A,Employees E,Locations L where A.TagID='" + TagID + "' or E.TagID='" + TagID + "' or L.TagID='" + TagID + "'";
                    ////select count(*) from Locations where TagID='" + TagID + "'";
                    //if (Convert.ToInt32(localDB.getScalerValue(strSql)) > 0)
                    //    throw new ApplicationException("Duplicate Tag ID.");

                    strSql  = " insert into Locations(TagID,Name,LocationNo,Date_Modified,ModifiedBy,RowStatus,serverKey)";
                    strSql += " values('" + TagID + "','" + LocationName.Replace("'", "''") + "','" + LocationNo.Replace("'", "''") + "',getDate()," + Login.ID + "," + Convert.ToInt32(RowStatus.New) + "," + Skey + ")";
                    localDB.runQuery(strSql);
                }
            }
            else
            {
                DataTable dtLocation = new DataTable("dtLocation");

                dtLocation.Columns.Add("TagID", typeof(String));
                dtLocation.Columns.Add("Name", typeof(String));
                dtLocation.Columns.Add("LocationNo", typeof(String));
                dtLocation.Columns.Add("Date_Modified", typeof(DateTime));
                dtLocation.Columns.Add("ModifiedBy", typeof(Int32));
                dtLocation.AcceptChanges();

                DataRow dr;
                dr = dtLocation.NewRow();

                dr["TagID"]         = TagID;
                dr["Name"]          = LocationName;
                dr["LocationNo"]    = LocationNo;
                dr["Date_Modified"] = DateTime.Now;
                dr["ModifiedBy"]    = Login.ID;

                dtLocation.Rows.Add(dr);
                dtLocation.AcceptChanges();

                Synchronize.Synchronise OnConn = new Synchronize.Synchronise();
                OnConn.Url = Login.webURL;
                DataTable dtResult;
                dtResult = OnConn.AddLocation(dtLocation);

                if (dtResult.Rows.Count != 0)
                {
                    if (Convert.ToInt32(dtResult.Rows[0]["RowStatus"]) == Convert.ToInt32(RowStatus.Error))
                    {
                        throw new ApplicationException("Insert Failed.");
                    }
                    else
                    {
                        //Inserted Sucessfully
                    }
                }
                //throw new ApplicationException("Online functionality of Location not implemented yet.");
            }
        }