Esempio n. 1
0
        public static ResultEN Insert_Equip(EquiptmentEN en)
        {
            // SqlCommand sqlCmd = new SqlCommand();
            // sqlCmd.CommandText = "insert into " + tb_name_type +" ()";


            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            fields.Add(new ClassFieldValue("Name", en.Name));
            fields.Add(new ClassFieldValue("Fullname", en.Fullname));
            fields.Add(new ClassFieldValue("Equip_type_id", en.Equip_type_id));
            fields.Add(new ClassFieldValue("Number", en.EquipNo));
            fields.Add(new ClassFieldValue("SN", en.SN));
            fields.Add(new ClassFieldValue("SupplierName", en.SupplierName));
            fields.Add(new ClassFieldValue("ReceiptTax", en.ReceiptTax));
            fields.Add(new ClassFieldValue("BuyDate", en.BuyDate));
            fields.Add(new ClassFieldValue("CostBuy", en.CostBuy));
            fields.Add(new ClassFieldValue("CostRent", en.CostRent));
            fields.Add(new ClassFieldValue("ExpireDate", en.ExpireDate));

            fields.Add(new ClassFieldValue("CreatedBy", HttpContext.Current.User.Identity.Name));
            fields.Add(new ClassFieldValue("CreatedDate", DateTime.Now));
            ResultEN res = new ResultEN();

            res = ClassMain.Insert(tb_name_master, fields);


            return(res);
        }
Esempio n. 2
0
        public void DeleteResult(int id
                                 )
        {
            try
            {
                SessionInitializeTransaction();
                ResultEN resultEN = (ResultEN)session.Load(typeof(ResultEN), id);
                session.Delete(resultEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in ResultCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Esempio n. 3
0
        public int NewResult(ResultEN result)
        {
            try
            {
                SessionInitializeTransaction();
                if (result.Event_rel != null)
                {
                    // Argumento OID y no colección.
                    result.Event_rel = (PickadosGenNHibernate.EN.Pickados.Event_EN)session.Load(typeof(PickadosGenNHibernate.EN.Pickados.Event_EN), result.Event_rel.Id);

                    result.Event_rel.Pick_rel
                    .Add(result);
                }

                session.Save(result);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in ResultCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(result.Id);
        }
Esempio n. 4
0
        public int NewResult(double p_odd, string p_description, PickadosGenNHibernate.Enumerated.Pickados.PickResultEnum p_pickResult, string p_bookie, int p_event_rel, PickadosGenNHibernate.Enumerated.Pickados.ResultEnum p_result, PickadosGenNHibernate.Enumerated.Pickados.TimeEnum p_matchtime)
        {
            ResultEN resultEN = null;
            int      oid;

            //Initialized ResultEN
            resultEN     = new ResultEN();
            resultEN.Odd = p_odd;

            resultEN.Description = p_description;

            resultEN.PickResult = p_pickResult;

            resultEN.Bookie = p_bookie;


            if (p_event_rel != -1)
            {
                // El argumento p_event_rel -> Property event_rel es oid = false
                // Lista de oids id
                resultEN.Event_rel    = new PickadosGenNHibernate.EN.Pickados.Event_EN();
                resultEN.Event_rel.Id = p_event_rel;
            }

            resultEN.Result = p_result;

            resultEN.Matchtime = p_matchtime;

            //Call to ResultCAD

            oid = _IResultCAD.NewResult(resultEN);
            return(oid);
        }
Esempio n. 5
0
        public ResultEN ReadOIDDefault(int id
                                       )
        {
            ResultEN resultEN = null;

            try
            {
                SessionInitializeTransaction();
                resultEN = (ResultEN)session.Get(typeof(ResultEN), id);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in ResultCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(resultEN);
        }
Esempio n. 6
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(ResultEN result)
        {
            try
            {
                SessionInitializeTransaction();
                ResultEN resultEN = (ResultEN)session.Load(typeof(ResultEN), result.Id);

                resultEN.Result = result.Result;


                resultEN.Matchtime = result.Matchtime;

                session.Update(resultEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is PickadosGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new PickadosGenNHibernate.Exceptions.DataLayerException("Error in ResultCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Esempio n. 7
0
        public static ResultEN Update_Equip(EquiptmentEN en)
        {
            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            fields.Add(new ClassFieldValue("Name", en.Name));
            fields.Add(new ClassFieldValue("Fullname", en.Fullname));
            fields.Add(new ClassFieldValue("Equip_type_id", en.Equip_type_id));
            fields.Add(new ClassFieldValue("Number", en.EquipNo));
            fields.Add(new ClassFieldValue("SN", en.SN));
            fields.Add(new ClassFieldValue("SupplierName", en.SupplierName));
            fields.Add(new ClassFieldValue("ReceiptTax", en.ReceiptTax));
            fields.Add(new ClassFieldValue("BuyDate", en.BuyDate));
            fields.Add(new ClassFieldValue("CostBuy", en.CostBuy));
            fields.Add(new ClassFieldValue("CostRent", en.CostRent));
            fields.Add(new ClassFieldValue("ExpireDate", en.ExpireDate));

            fields.Add(new ClassFieldValue("UpdatedBy", HttpContext.Current.User.Identity.Name));
            fields.Add(new ClassFieldValue("UpdatedDate", DateTime.Now));
            ResultEN res = new ResultEN();

            List <ClassFieldValue> fieldWhere = new List <ClassFieldValue>();

            fieldWhere.Add(new ClassFieldValue("ID", en.ID));
            res = ClassMain.Update(tb_name_master, fields, fieldWhere);

            return(res);
        }
Esempio n. 8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ResultEN res = new ResultEN();

            if (mode == "add")
            {
                int branch_id = 0;
                int role_id   = 3;
                if (Session["selectbranch"] != null)
                {
                    branch_id = Convert.ToInt32(Session["selectbranch"]);
                }

                role_id = Convert.ToInt32(rdbRole.SelectedValue);

                res = ClassUser.CreateUser(inputUsername.Text, inputPassword.Text, role_id, branch_id);
                if (res.result)
                {
                    BindGrid();

                    ShowMessage("Created user success.");
                    SetDefaultControl();
                }
            }
            else
            {
                ClassUser.ChangePassword(inputUsername.Text, inputPassword.Text);
                SetDefaultControl();

                ShowMessage("Changed Password success.");
            }
        }
Esempio n. 9
0
        public static ResultEN Delete(int id)
        {
            ResultEN res = new ResultEN();
            string   sql = "DELETE From Employees Where id=" + id;

            res.result = ClassMain.ExecuteQuery(sql);
            return(res);
        }
Esempio n. 10
0
        public static ResultEN Delete(string C_ID)
        {
            ResultEN res = new ResultEN();
            string   sql = "DELETE From Customer Where C_ID='" + C_ID + "'";

            res.result = ClassMain.ExecuteQuery(sql);
            return(res);
        }
Esempio n. 11
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ResultEN res = ClassEuipt.Delete_Type(SelectedItem);

            MessageShow("ลบรายการเรียบร้อยแล้ว");
            BindGrid();
            BindTree();
            SetDefaultControl();
        }
Esempio n. 12
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ResultEN res = ClassEmployee.Delete(this.SelectedID);

            if (res.result == true)
            {
                MessageShow("ลบข้อมูลเรียบร้อยแล้ว");
                SetDefult();
                BindGrid();
            }
        }
Esempio n. 13
0
        public static ResultEN Delete_Type(EquiptmentEN en)
        {
            ResultEN   res    = new ResultEN();
            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "Delete From " + tb_name_master + " WHERE ID = " + en.ID;
            sqlCmd.CommandType = CommandType.Text;

            res.result = ClassMain.ExecuteComand(sqlCmd);

            return(res);
        }
Esempio n. 14
0
        private void Save()
        {
            ResultEN     res = new ResultEN();
            EquiptmentEN en  = new EquiptmentEN();


            switch (mode)
            {
            case "add":

                SetItem(en);

                res = ClassEuipt.Insert_Equip(en);
                break;


            case "edit":
                en = this.SelectedEquip;
                SetItem(en);

                res = ClassEuipt.Update_Equip(en);
                break;

            default:
                break;
            }


            //if (mode == "add")
            //{
            //    EquiptmentEN en = new EquiptmentEN();
            //    SetItem(en);

            //    res = ClassEuipt.Insert_Equip(en);

            //}
            //else
            //{
            //    EquiptmentEN en = this.SelectedEquip;
            //    SetItem(en);

            //    res = ClassEuipt.Update_Equip(en);
            //}

            if (res.result)
            {
                MessageShow("บันทึกเรียบร้อยแล้ว");
                BindGrid();
                BindTree();
                SetDefult();
                this.SelectedItem = null;
            }
        }
Esempio n. 15
0
        public static ResultEN Insert_Equipment_SET(ref Equipment_SET en)
        {
            ResultEN res = new ResultEN();

            // int? _Id = GetID("Equipment_SET", "SET_ID");
            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            //en.SET_ID = _Id.Value;
            fields = SetField_SET(fields, en);

            res = ClassMain.Insert("Equipment_SET", fields, "SET_ID");
            return(res);
        }
Esempio n. 16
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string   C_ID      = this.txtC_ID.Text;
            ResultEN ResultENs = ClassCustomer.Delete(C_ID);

            if (ResultENs != null && ResultENs.result)
            {
                LoadData();
                set();
            }
            else
            {
            }
        }
Esempio n. 17
0
    public static ResultEN CreateUser(string username, string password, int role_id, int branch_id)
    {
        ResultEN res = new ResultEN();

        username = username.Trim().ToLower();
        SqlCommand sqlCmd = new SqlCommand();

        sqlCmd.CommandText = "select username from Users where username ='******'";

        // check duplicate username
        int count = ClassMain.intExecuteComand(sqlCmd);

        if (count > 0)
        {
            res.result      = false;
            res.returnValue = "Duplicate Username";
            return(res);
        }


        string strEnCrypt = SHA256.EcryptPassword(password, salt);

        StringBuilder Sql = new StringBuilder();

        Sql.AppendLine("INSERT INTO [dbo].[Users]");
        Sql.AppendLine("           ([Username]");
        Sql.AppendLine("           ,[Password]");
        Sql.AppendLine("           ,[Role_id]");
        Sql.AppendLine("           ,[CreatedDate]");
        Sql.AppendLine("           ,[CreatedBy]");

        Sql.AppendLine(")");
        Sql.AppendLine("     VALUES");
        Sql.AppendLine("           ('" + username + "'");
        Sql.AppendLine("           ,'" + strEnCrypt + "'");
        Sql.AppendLine("           ," + role_id);
        Sql.AppendLine("           ,getdate()");
        Sql.AppendLine("           ,'" + HttpContext.Current.User.Identity.Name + "')");

        sqlCmd             = new SqlCommand();
        sqlCmd.CommandText = Sql.ToString();
        res.result         = ClassMain.ExecuteComand(sqlCmd);
        if (res.result)
        {
            res.returnValue = "Create Username Success.";
        }

        return(res);
    }
Esempio n. 18
0
        public static ResultEN InsertPosition_Emp(JobPosition_EmpEN en)
        {
            ResultEN res = new ResultEN();

            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            fields.Add(new ClassFieldValue("Emp_id", en.empid));
            fields.Add(new ClassFieldValue("Pos_id", en.posid));
            fields.Add(new ClassFieldValue("cost", en.cost));
            fields.Add(new ClassFieldValue("CreatedDate", DateTime.Now));
            fields.Add(new ClassFieldValue("CreatedBy", HttpContext.Current.User.Identity.Name));

            res = ClassMain.Insert(tb_name_jopEmp, fields);
            return(res);
        }
Esempio n. 19
0
        private void Delete()
        {
            if (VSSet_Id != null)
            {
                int?[]   _set_id       = { VSSet_Id };
                ResultEN result_detail = ClassSet.Delete_Equipment_SET_detail(_set_id);
                if (result_detail != null && result_detail.result)
                {
                    ResultEN result_Set_detail = ClassSet.Delete_Equipment_SET(_set_id);

                    string message = "ลบสำเร็จ";
                    MessageShow(message);
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "ToggleScript", "Alert(" + message + ")", true);
                }
            }
        }
Esempio n. 20
0
        public static ResultEN Update(CustomerEN en)
        {
            ResultEN res = new ResultEN();
            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            fields.Add(new ClassFieldValue("UpdatedBy", HttpContext.Current.User.Identity.Name));
            fields.Add(new ClassFieldValue("UpdatedDate", DateTime.Now));
            SetField(fields, en);

            List <ClassFieldValue> fieldscon = new List <ClassFieldValue>();

            fieldscon.Add(new ClassFieldValue("C_ID", en.C_ID));

            res = ClassMain.Update(tb_name, fields, fieldscon);
            return(res);
        }
Esempio n. 21
0
        public static ResultEN Insert(CustomerEN en)
        {
            ResultEN res = new ResultEN();
            // Gen Employee code
            string C_ID = GetC_ID();
            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            en.C_ID = C_ID;
            //fields.Add(new ClassFieldValue("C_ID", C_ID));
            fields.Add(new ClassFieldValue("CreatedBy", HttpContext.Current.User.Identity.Name));
            fields.Add(new ClassFieldValue("CreatedDate", DateTime.Now));
            SetField(fields, en);

            res = ClassMain.Insert(tb_name, fields);
            return(res);
        }
Esempio n. 22
0
        public void ModifyResult(int p_Result_OID, double p_odd, string p_description, PickadosGenNHibernate.Enumerated.Pickados.PickResultEnum p_pickResult, string p_bookie, PickadosGenNHibernate.Enumerated.Pickados.ResultEnum p_result, PickadosGenNHibernate.Enumerated.Pickados.TimeEnum p_matchtime)
        {
            ResultEN resultEN = null;

            //Initialized ResultEN
            resultEN             = new ResultEN();
            resultEN.Id          = p_Result_OID;
            resultEN.Odd         = p_odd;
            resultEN.Description = p_description;
            resultEN.PickResult  = p_pickResult;
            resultEN.Bookie      = p_bookie;
            resultEN.Result      = p_result;
            resultEN.Matchtime   = p_matchtime;
            //Call to ResultCAD

            _IResultCAD.ModifyResult(resultEN);
        }
Esempio n. 23
0
    public static ResultEN Update(string tb_name, List <ClassFieldValue> fields, List <ClassFieldValue> keyVals)
    {
        ResultEN res = new ResultEN();

        res.result = false;

        SqlCommand sqlCom = new SqlCommand();

        SqlConnection Conn = ConnDB();

        Conn.Open();
        if (sqlCom.Connection == null)
        {
            sqlCom.Connection = Conn;
        }

        sqlCom.CommandType    = CommandType.Text;
        sqlCom.CommandTimeout = 0;
        sqlCom.CommandText    = getUpdateQueryString(tb_name, fields, keyVals);


        Int32 intValue = 0;

        try
        {
            intValue = Convert.ToInt32(sqlCom.ExecuteScalar());
            Conn.Close();
            res.result      = true;
            res.returnValue = intValue;
        }
        catch (Exception)
        {
            intValue = -1;
            Conn.Close();
            res.result      = false;
            res.returnValue = intValue;
            throw;
        }
        finally
        {
            Conn.Close();
        }

        return(res);
    }
Esempio n. 24
0
        public static ResultEN Delete_Type(EquipmentTypeEN en)
        {
            ResultEN   res    = new ResultEN();
            SqlCommand sqlCmd = new SqlCommand();

            sqlCmd.CommandText = "Delete From " + tb_name_type + " WHERE ParentID = " + en.ID;
            sqlCmd.CommandType = CommandType.Text;

            // delete child
            res.result = ClassMain.ExecuteComand(sqlCmd);


            // delete parent
            sqlCmd.CommandText = "Delete From " + tb_name_type + " WHERE ID = " + en.ID;
            res.result         = ClassMain.ExecuteComand(sqlCmd);

            return(res);
        }
Esempio n. 25
0
        public static ResultEN Insert_Type(EquipmentTypeEN en)
        {
            // SqlCommand sqlCmd = new SqlCommand();
            // sqlCmd.CommandText = "insert into " + tb_name_type +" ()";


            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            fields.Add(new ClassFieldValue("TypeName", en.TypeName));
            fields.Add(new ClassFieldValue("ParentID", en.ParentID));
            fields.Add(new ClassFieldValue("CreatedBy", HttpContext.Current.User.Identity.Name));
            fields.Add(new ClassFieldValue("CreatedDate", DateTime.Now));
            ResultEN res = new ResultEN();

            // ClassMain cls = new ClassMain();
            res = ClassMain.Insert(tb_name_type, fields);


            return(res);
        }
Esempio n. 26
0
        public static ResultEN Insert(EmployeeEN en)
        {
            ResultEN res = new ResultEN();

            // Gen Employee code
            System.Globalization.CultureInfo cultureinfo = new System.Globalization.CultureInfo("en-US");
            string code = "E" + DateTime.Now.Date.Year.ToString(cultureinfo);

            string runno = GetRunno();

            code += runno;

            List <ClassFieldValue> fields = new List <ClassFieldValue>();

            fields.Add(new ClassFieldValue("Emp_id", code));
            fields.Add(new ClassFieldValue("CreatedBy", HttpContext.Current.User.Identity.Name));
            fields.Add(new ClassFieldValue("CreatedDate", DateTime.Now));
            SetField(fields, en);


            res = ClassMain.Insert(tb_name, fields);
            return(res);
        }
Esempio n. 27
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ResultEN res = new ResultEN();

            if (mode == "add")
            {
                EquipmentTypeEN en = new EquipmentTypeEN();
                if (Level == 0)
                {
                    en.TypeName = txtTypeName.Text;
                }
                else
                {
                    en.TypeName = txtSubName.Text;
                }

                en.ParentID = Convert.ToInt32(hidParentID.Value);

                res = ClassEuipt.Insert_Type(en);
            }
            else
            {
                SetData();
                EquipmentTypeEN en = new EquipmentTypeEN();
                en  = SelectedItem;
                res = ClassEuipt.Update_Type(en);
            }

            if (res.result)
            {
                MessageShow("บันทึกเรียบร้อยแล้ว");
                BindGrid();
                BindTree();
                SetDefaultControl();
                this.SelectedItem = null;
            }
        }
Esempio n. 28
0
    public static ResultEN ChangeUsername(int id, string username_old, string username_new, string password)
    {
        ResultEN   res    = new ResultEN();
        SqlCommand sqlCmd = new SqlCommand();

        username_old       = username_old.Trim().ToLower();
        username_new       = username_new.Trim().ToLower();
        sqlCmd.CommandText = "select username from Users where username ='******' and username <> '" + username_old + "'";

        // check duplicate username not self
        int count = ClassMain.intExecuteComand(sqlCmd);

        if (count > 0)
        {
            res.result      = false;
            res.returnValue = "Duplicate Username";
            return(res);
        }

        string strEnCrypt = SHA256.EcryptPassword(password, salt);

        sqlCmd = new SqlCommand();
        StringBuilder Sql = new StringBuilder();

        Sql.AppendLine("UPDATE [dbo].[Users]");
        Sql.AppendLine("   SET [Username] = '" + username_new + "'");
        Sql.AppendLine("      ,[Password] = '" + strEnCrypt + "'");
        Sql.AppendLine("      ,[UpdDate] = getdate()");
        Sql.AppendLine("      ,[UpdTime] = getdate()");
        Sql.AppendLine("      ,[UpdBy] = '" + HttpContext.Current.User.Identity.Name + "'");
        Sql.AppendLine(" WHERE id = " + id);
        sqlCmd.CommandText = sqlCmd.ToString();

        res.result = ClassMain.ExecuteComand(sqlCmd);
        return(res);
    }
Esempio n. 29
0
        public static ResultEN Delete_Equipment_SET_detail(int?[] SET_ID)
        {
            ResultEN res       = new ResultEN();
            string   condition = "";

            if (SET_ID != null)
            {
                if (condition == "")
                {
                    condition = condition + "WHERE\n    ";
                }
                else
                {
                    condition = condition + "   AND ";
                }

                condition = condition + "SET_ID in (";

                string str_id = "";
                foreach (var id in SET_ID)
                {
                    if (!string.IsNullOrEmpty(str_id))
                    {
                        str_id += ",";
                    }
                    str_id = str_id + id;
                }

                condition = condition + " " + str_id + " ) \n";
            }

            string sql = "DELETE From Equipment_SET_detail " + condition;

            res.result = ClassMain.ExecuteQuery(sql);
            return(res);
        }
Esempio n. 30
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ResultEN   ResultENs   = new ResultEN();
            CustomerEN CustomerENs = new CustomerEN();

            CustomerENs.C_ID         = this.txtC_ID.Text;
            CustomerENs.Name         = this.txtName.Text;
            CustomerENs.Tel          = this.txtTel.Text;
            CustomerENs.Email        = this.txtEmail.Text;
            CustomerENs.Fax          = this.txtFax.Text;
            CustomerENs.Name_Company = this.txtCompany.Text;
            CustomerENs.Tel_Company  = this.txtTel_Company.Text;
            CustomerENs.Address      = this.txtAddress.Text;
            CustomerENs.Tax_Number   = this.txtTax_Number.Text;

            if (Enum_Mode.Add.GetHashCode() == mode)
            {
                CustomerENs.CreatedBy   = "";
                CustomerENs.CreatedDate = DateTime.Now;
                ResultENs = ClassCustomer.Insert(CustomerENs);
            }
            else if (Enum_Mode.Edit.GetHashCode() == mode)
            {
                CustomerENs.UpdatedBy   = "";
                CustomerENs.UpdatedDate = DateTime.Now;
                ResultENs = ClassCustomer.Update(CustomerENs);
            }

            if (ResultENs != null && ResultENs.result)
            {
                LoadData();
            }
            else
            {
            }
        }