コード例 #1
0
ファイル: idocEmployee.cs プロジェクト: Victor-UA/ASF
        public override void Save()
        {
            string SQL = qryEmployeeSave;

            try
            {
                if (!Owner.isCreated)
                {
                    Owner = Program.UserContext;
                }
                SQL = SQL.Replace(":empid", Key.ToString());
                SQL = SQL.Replace(":persontitle", "'" + Title.ToString() + "'");
                SQL = SQL.Replace(":personname", "'" + Name.ToString() + "'");
                SQL = SQL.Replace(":personmiddle", "'" + Middlename.ToString() + "'");
                SQL = SQL.Replace(":personlastname", "'" + Surname.ToString() + "'");

                SQL = SQL.Replace(":_phone", Phone.ToString() == "" ? "null" : "'" + Phone.ToString() + "'");

                SQL = SQL.Replace(":city", "'" + City.ToString() + "'");
                SQL = SQL.Replace(":country", "'" + Country.ToString() + "'");
                SQL = SQL.Replace(":region", "'" + Region.ToString() + "'");
                SQL = SQL.Replace(":district", "'" + District.ToString() + "'");
                SQL = SQL.Replace(":_address", "'" + Address.ToString() + "'");
                SQL = SQL.Replace(":postalcode", "'" + PostalCode.ToString() + "'");

                SQL = SQL.Replace(":dateborn", "'" + Birthday.ToString() + "'");

                SQL = SQL.Replace(":_email", "'" + Email.ToString() + "'");

                SQL = SQL.Replace(":rcomment", "'" + RComment.ToString() + "'");
                SQL = SQL.Replace(":ownerid", isCreated ? Owner.Key : Program.UserContext.Key);

                SQL = SQL.Replace(":locked", Locked ? "1" : "0");
                SQL = SQL.Replace(":username", "'" + UserName.ToString() + "'");
                SQL = SQL.Replace(":userpassword", "'" + Encryption.Encode(UserPassword.ToString(), Program.PasswordKey) + "'");

                Client.ExecuteSQLCommit(SQL);

                Owner.Load();
                MainForm.toolStripStatusOwner.Text = Owner.Title;

                isChanged = false;
                isCreated = true;
                Program.EmployeesAreChanged = true;
                Program.RefreshEmployee(this);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "\n");
            }
        }