コード例 #1
0
		async void CustomerSave_Click(object sender, RoutedEventArgs e)
		{
			_cInfo.LastModified = DateTime.Now;
			//_cInfo.Notes = rtbNotes.GetRTF();
			
			if (_cInfo == null || _cInfo.SQLID == 0)
			{
				_cInfo = DBAbstract.CreateCustomer(_cInfo);
				CloseableTabItem tbi = new CloseableTabItem();
				CustomerNotes ctn = new CustomerTrackerWPF.CustomerNotes(_cInfo);
				var header = new TextBlock { Text = _cInfo.FirstName + " " + _cInfo.LastName, VerticalAlignment = VerticalAlignment.Bottom};
				tbi.SetHeader(header);
				tbi.Content = ctn;
				tbi.Click += (ssender, le) =>
				{
					CustomerTrackerWPF.Window1.mainWindow.CloseTabButton_OnClick(ssender, le);
				};
				ctn.VerticalAlignment = VerticalAlignment.Top;
				CustomerTrackerWPF.Window1.mainWindow.mTabControl.Items.Add(tbi);
				CustomerTrackerWPF.Window1.mainWindow.mTabControl.SelectedItem = tbi;
				ClearItUp();
			}
			else
			{
				bool success = DBAbstract.UpdateCustomer(_cInfo);
				if (!success)
				{
					await Window1.mainWindow.ShowMessage("Failed to update customer information", "Update Failed", MessageDialogStyle.Affirmative);
					return;
				}
				_isDirty = false;
				//rtbNotes.isDirty = false;
			}
		}
コード例 #2
0
		public CustomerNotes(int cid)
		{
			InitializeComponent();
			
			_cInfo = DBAbstract.FindCustomerByID(cid);
			this.DataContext = _cInfo;
		}
コード例 #3
0
		public CustomerNotes(CustomerInformation cInfo)
		{
			InitializeComponent();
			
			_cInfo = cInfo;
			this.DataContext = _cInfo;
		}
コード例 #4
0
        void LookUpSearch_Click(object sender, RoutedEventArgs e)
        {
            DataTable customer;
            CustomerInformation cinfo = new CustomerInformation(iftFirstName.Text,iftLastName.Text,iftPhoneNumber.Text, iftEMail.Text,iftCompanyName.Text,"",0, dateTimePicker1.SelectedDate);

            customer = DBAbstract.FindCustomer(cinfo, false,chbLastUpdated.IsChecked);
            lviewResults.ItemsSource = null;
            lviewResults.Items.Clear();
            lviewResults.ItemsSource = customer.DefaultView;
            customer.Dispose();
        }
コード例 #5
0
		public Attachments(CustomerInformation cinfo)
		{
			InitializeComponent();
			_cInfo = cinfo;
			
			if (!Directory.Exists(CTGlobals.Settings.AttachmentsFolder + _cInfo.SQLID.ToString()))
				Directory.CreateDirectory(CTGlobals.Settings.AttachmentsFolder + _cInfo.SQLID.ToString());
			
			//string root = System.IO.Path.GetDirectoryName(CTGlobals.Settings.AttachmentsFolder + _cInfo.SQLID.ToString());
			UpdateList();
			
		}
コード例 #6
0
ファイル: Server.cs プロジェクト: qsqurrl/CustomerTrackerWPF
        public CustomerInformation CreateCustomer(CustomerInformation cinfo)
        {
            global::CustomerInformation ci = new global::CustomerInformation();
            ci.CompanyName = cinfo.CompanyName;
            ci.EMail = cinfo.EMail;
            ci.FirstName = cinfo.FirstName;
            ci.LastModified = Convert.ToDateTime(cinfo.LastModified);
            ci.LastModifiedSpecified = true;
            ci.LastName = cinfo.LastName;
            ci.Notes = cinfo.Notes;
            ci.PhoneNumber = cinfo.PhoneNumber;
            //ci.SQLID = cinfo.SQLID;

            CreateCustomerRequest creq = new CreateCustomerRequest(ci);
            Task<CreateCustomerResponse> cres =  _sqlService.CreateCustomerAsync(creq);
            ci = cres.Result.CreateCustomerResult;
            return new CustomerInformation(ci.FirstName,ci.LastName,ci.PhoneNumber,ci.EMail,ci.CompanyName,ci.Notes,ci.SQLID,cinfo.LastModified);
        }
コード例 #7
0
 public CustomerInformation CreateCustomer(CustomerInformation cinfo)
 {
     sqlconn.Open();
     SQLiteCommand cmd = new SQLiteCommand(_createCommandText, sqlconn);
     cmd.Parameters.AddWithValue("@cfirstname", cinfo.FirstName);
     cmd.Parameters.AddWithValue("@clastname", cinfo.LastName);
     cmd.Parameters.AddWithValue("@cphonenumber", cinfo.PhoneNumber);
     cmd.Parameters.AddWithValue("@cemail", cinfo.EMail);
     cmd.Parameters.AddWithValue("@cconame", cinfo.CompanyName);
     cmd.Parameters.AddWithValue("@cnotes", cinfo.Notes);
     cmd.Parameters.AddWithValue("@clastmodified", cinfo.LastModified.ToString());
     try {
         cmd.ExecuteNonQuery();
         sqlconn.Close();
         return FindCustomerC(cinfo, true);
     } catch (Exception ex) {
         MessageBox.Show(ex.Message);
         sqlconn.Close();
         return null;
     }
 }
コード例 #8
0
ファイル: Server.cs プロジェクト: qsqurrl/CustomerTrackerWPF
        public DataTable FindCustomer(CustomerInformation cinfo, bool strict, bool? bytime)
        {
            global::CustomerInformation ci = new global::CustomerInformation();
            ci.CompanyName = cinfo.CompanyName;
            ci.EMail = cinfo.EMail;
            ci.FirstName = cinfo.FirstName;
            if ((bool)bytime)
            {
                ci.LastModified = (Convert.ToDateTime(cinfo.LastModified));
                ci.LastModifiedSpecified = true;
            } else { ci.LastModifiedSpecified = false; }
            ci.LastName = cinfo.LastName;
            ci.Notes = cinfo.Notes;
            ci.PhoneNumber = cinfo.PhoneNumber;
            ci.SQLID = cinfo.SQLID;
            ci.SQLIDSpecified = true;

            FindCustomerRequest fcreq = new FindCustomerRequest(ci,strict,bytime);

            Task<FindCustomerResponse> fcres = _sqlService.FindCustomerAsync(fcreq);

            return fcres.Result.FindCustomerResult;
        }
コード例 #9
0
        public CustomerInformation FindCustomerByID(int cID)
        {
            DataTable dt = new DataTable();
            CustomerInformation ci = new CustomerInformation();

            String commandText = "SELECT * FROM customer ";
            String swhere = "WHERE";
            sqlconn.Open();
            SQLiteCommand cmd = new SQLiteCommand(sqlconn);

            cmd.Parameters.AddWithValue("@cid", cID);
            swhere += " cID = @cid;";
            commandText += swhere;
            cmd.CommandText = commandText;
            SQLiteDataReader reader = cmd.ExecuteReader();
            dt.Load(reader);
            reader.Close();
            sqlconn.Close();
            foreach (DataRow r in dt.Rows) {
                ci.FirstName = r["cFirstName"].ToString();
                ci.LastName = r["cLastName"].ToString();
                ci.CompanyName = r["cCoName"].ToString();
                ci.EMail = r["cEMail"].ToString();
                ci.LastModified = DateTime.Parse(r["cLastModified"].ToString());
                ci.Notes = r["cNotes"].ToString();
                ci.PhoneNumber = r["cPhoneNumber"].ToString();
                ci.SQLID = Convert.ToInt32(r["cID"].ToString());
            }
            return ci;
        }
コード例 #10
0
		void Importold_Click(object sender, RoutedEventArgs e)
		{
			
			var olddbfilename = (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)) + "\\DistNote\\distnotedb.s3db";
			importProgress.Value = 0;
			
			if (!File.Exists(olddbfilename)) {
				CTGlobals.Settings.ImportedOldDB = true;
				return;
			}
			
			string olddbconnectionstring = string.Format("Data Source= {0}", (olddbfilename));
			String commandText = "SELECT * FROM Customer";
			CustomerInformation ci = new CustomerInformation();
			CustomerInformation cr = new CustomerInformation();
			
			SQLiteConnection oconn = new SQLiteConnection(olddbconnectionstring);
			oconn.Open();
			SQLiteCommand cmd = new SQLiteCommand(commandText, oconn);
			DataTable dt = new DataTable();
			
			SQLiteDataReader reader = cmd.ExecuteReader();
			dt.Load(reader);
			reader.Close();
			oconn.Close();
			
			string[] fnln = { };
			String name = "";
			String[] atts;
			String oldatt = "";
			String newatt = "";
			var rtb1 = new RichTextBox();
			
			importProgress.Maximum = dt.Rows.Count;
			
			foreach (DataRow r in dt.Rows) {
				name = r["cName"].ToString();
				fnln = name.Split(' ');
				ci.FirstName = fnln[0];
				if (fnln.Length > 1)
					ci.LastName = fnln[1];

				ci.CompanyName = string.Empty;
				ci.EMail = r["cEmail"].ToString();
				ci.LastModified = DateTime.Parse(r["cTouchTime"].ToString());
				
				Paragraph textParagraph = new Paragraph();
				rtb1.Document.Blocks.Clear();
				textParagraph.Inlines.Clear();
				rtb1.CaretPosition = rtb1.Document.ContentStart;
				
				textParagraph.Inlines.Add(r["cNotes"].ToString());
				rtb1.Document.Blocks.Add(textParagraph);
				TextRange textRange = new TextRange(rtb1.Document.ContentStart, rtb1.Document.ContentEnd);
				ci.Notes = textRange.Text;
				
				ci.PhoneNumber = r["cPhoneNumber"].ToString();
				ci.SQLID = 0;
				cr = DBAbstract.CreateCustomer(ci);
				
				if (cr != null) {
					oldatt = (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\DistNote\\" + r["cPK"].ToString() + "\\");
					newatt = (CTGlobals.Settings.AttachmentsFolder + cr.SQLID.ToString() + "\\");
					if (Directory.Exists(oldatt)) {
						if (!Directory.Exists(newatt)) {
							Directory.CreateDirectory(newatt);
							atts = Directory.GetFiles(oldatt);
						
							foreach (String s in atts) {
								File.Copy(s, newatt + Path.GetFileName(s));
							}
						}
					}
				}
				importProgress.Value++;
			}
			CTGlobals.Settings.ImportedOldDB = true;
			importold.IsEnabled = false;
		}
コード例 #11
0
 public static bool UpdateCustomer(CustomerInformation cinfo)
 {
     return (CTGlobals.Settings.isServer == true) ? _dbServer.UpdateCustomer(cinfo) : _sqlitedb.UpdateCustomer(cinfo);
 }
コード例 #12
0
 public static DataTable FindCustomer(CustomerInformation cinfo, bool strict, bool? bytime)
 {
     return (CTGlobals.Settings.isServer == true) ? _dbServer.FindCustomer(cinfo, strict, bytime) : _sqlitedb.FindCustomer(cinfo, strict, bytime);
 }
コード例 #13
0
 public Reminders(CustomerInformation cInfo)
 {
     InitializeComponent();
     _cInfo = cInfo;
     remDT.Value = DateTime.Now;
 }
コード例 #14
0
ファイル: Server.cs プロジェクト: qsqurrl/CustomerTrackerWPF
 public CustomerInformation FindCustomerByID(int cID)
 {
     global::CustomerInformation ci = new global::CustomerInformation();
     global::FindCustomerByIDResponse fcbid = new FindCustomerByIDResponse();
     FindCustomerByIDRequest fcbidq = new FindCustomerByIDRequest(cID);
     fcbid = _sqlService.FindCustomerByID(fcbidq);
     ci = fcbid.FindCustomerByIDResult;
     CustomerInformation co = new CustomerInformation(ci.FirstName, ci.LastName, ci.PhoneNumber, ci.EMail, ci.CompanyName, ci.Notes, ci.SQLID, Convert.ToDateTime(ci.LastModified));
     return co;
 }
コード例 #15
0
        public bool UpdateCustomer(CustomerInformation cinfo)
        {
            sqlconn.Open();
            SQLiteCommand cmd = new SQLiteCommand(_updateCommandText, sqlconn);
            cmd.Parameters.AddWithValue("@cfirstname", cinfo.FirstName);
            cmd.Parameters.AddWithValue("@clastname", cinfo.LastName);
            cmd.Parameters.AddWithValue("@cphonenumber", cinfo.PhoneNumber);
            cmd.Parameters.AddWithValue("@cemail", cinfo.EMail);
            cmd.Parameters.AddWithValue("@cnotes", cinfo.Notes);
            cmd.Parameters.AddWithValue("@cconame", cinfo.CompanyName);
            cmd.Parameters.AddWithValue("@clastmodified", cinfo.LastModified.ToString());
            cmd.Parameters.AddWithValue("@cid", cinfo.SQLID);

            try {
                cmd.ExecuteNonQuery();
                sqlconn.Close();
                return true;
            } catch (Exception fail) {
                MessageBox.Show(fail.Message);
                sqlconn.Close();
                return false;
            }
        }
コード例 #16
0
        private CustomerInformation FindCustomerC(CustomerInformation cinfo, bool strict)
        {
            DataTable dt = new DataTable();
            CustomerInformation ci = new CustomerInformation();

            String commandText = "SELECT * FROM customer ";
            String swhere = "WHERE";
            sqlconn.ConnectionString = CTGlobals.Settings.SQLiteConnectionString;
            sqlconn.Open();
            SQLiteCommand cmd = new SQLiteCommand(sqlconn);

            if (strict) {
                if (!string.IsNullOrEmpty(cinfo.FirstName)) {
                    cmd.Parameters.AddWithValue("@cfirstname", cinfo.FirstName);
                    swhere += " cFirstName = @cfirstname and";
                }
                if (!string.IsNullOrEmpty(cinfo.LastName)) {
                    cmd.Parameters.AddWithValue("@clastname", cinfo.LastName);
                    swhere += " cLastName = @clastname and";
                }
                if (!string.IsNullOrEmpty(cinfo.CompanyName)) {
                    cmd.Parameters.AddWithValue("@cconame", cinfo.CompanyName);
                    swhere += " cCoName = @cconame and";
                }
                if (!string.IsNullOrEmpty(cinfo.PhoneNumber)) {
                    cmd.Parameters.AddWithValue("@cphonenumber", cinfo.PhoneNumber);
                    swhere += " cPhoneNumber = @cphonenumber and";
                }
                if (!string.IsNullOrEmpty(cinfo.EMail)) {
                    cmd.Parameters.AddWithValue("@cemail", cinfo.EMail);
                    swhere += " cEMail = @cemail and";
                }
                if (!string.IsNullOrEmpty(cinfo.Notes)) {
                    cmd.Parameters.AddWithValue("@cnotes", cinfo.Notes);
                    swhere += " cNotes = @cnotes and";
                }
            } else {
                if (!string.IsNullOrEmpty(cinfo.FirstName)) {
                    cmd.Parameters.AddWithValue("@cfirstname", "%" + cinfo.FirstName + "%");
                    swhere += " cFirstName like @cfirstname and";
                }
                if (!string.IsNullOrEmpty(cinfo.LastName)) {
                    cmd.Parameters.AddWithValue("@clastname", cinfo.LastName);
                    swhere += " cLastName = @clastname and";
                }
                if (!string.IsNullOrEmpty(cinfo.CompanyName)) {
                    cmd.Parameters.AddWithValue("@cconame", "%" + cinfo.CompanyName + "%");
                    swhere += " cCoName like @cconame and";
                }
                if (!string.IsNullOrEmpty(cinfo.PhoneNumber)) {
                    cmd.Parameters.AddWithValue("@cphonenumber", cinfo.PhoneNumber);
                    swhere += " cPhoneNumber = @cphonenumber and";
                }
                if (!string.IsNullOrEmpty(cinfo.EMail)) {
                    cmd.Parameters.AddWithValue("@cemail", "%" + cinfo.EMail + "%");
                    swhere += " cEmail like @cemail and";
                }
                if (!string.IsNullOrEmpty(cinfo.Notes)) {
                    cmd.Parameters.AddWithValue("@cnotes", "%" + cinfo.Notes + "%");
                    swhere += " cNotes like @cnotes and";
                }
            }
            swhere = swhere.Remove((swhere.Length - 4), 4);
            commandText += swhere;
            cmd.CommandText = commandText;
            SQLiteDataReader reader = cmd.ExecuteReader();
            dt.Load(reader);
            reader.Close();
            sqlconn.Close();
            foreach (DataRow r in dt.Rows) {
                ci.FirstName = r["cFirstName"].ToString();
                ci.LastName = r["cLastName"].ToString();
                ci.CompanyName = r["cCoName"].ToString();
                ci.EMail = r["cEMail"].ToString();
                ci.LastModified = DateTime.Parse(r["cLastModified"].ToString());
                ci.Notes = r["cNotes"].ToString();
                ci.PhoneNumber = r["cPhoneNumber"].ToString();
                ci.SQLID = Convert.ToInt32(r["cID"].ToString());
            }
            return ci;
        }
コード例 #17
0
		private void ClearItUp()
		{
			LoopVisualTree(this);
			//rtbNotes.Clear();
			RichTextControl.Text = string.Empty;
			RichTextControl.Clear();
			RichTextControl.Document.Blocks.Clear();
			_hasLoaded = false;
			_isDirty = false;
			_cInfo = new CustomerInformation();
			this.DataContext = _cInfo;
		}
コード例 #18
0
        public DataTable FindCustomer(CustomerInformation cinfo, bool strict, bool? bytime)
        {
            DataTable dt = new DataTable();

            String commandText = "SELECT * FROM customer ";
            String swhere = "WHERE";
            sqlconn.Open();
            SQLiteCommand cmd = new SQLiteCommand(sqlconn);

            if (strict) {
                if (!string.IsNullOrEmpty(cinfo.FirstName)) {
                    cmd.Parameters.AddWithValue("@cfirstname", cinfo.FirstName);
                    swhere += " cFirstName = @cfirstname and";
                }
                if (!string.IsNullOrEmpty(cinfo.LastName)) {
                    cmd.Parameters.AddWithValue("@clastname", cinfo.LastName);
                    swhere += " cLastName = @clastname and";
                }
                if (!string.IsNullOrEmpty(cinfo.CompanyName)) {
                    cmd.Parameters.AddWithValue("@cconame", cinfo.CompanyName);
                    swhere += " cCoName = @cconame and";
                }
                if (!string.IsNullOrEmpty(cinfo.PhoneNumber)) {
                    cmd.Parameters.AddWithValue("@cphonenumber", cinfo.PhoneNumber);
                    swhere += " cPhoneNumber = @cphonenumber and";
                }
                if (!string.IsNullOrEmpty(cinfo.EMail)) {
                    cmd.Parameters.AddWithValue("@cemail", cinfo.EMail);
                    swhere += " cEMail = @cemail and";
                }
                if (!string.IsNullOrEmpty(cinfo.Notes)) {
                    cmd.Parameters.AddWithValue("@cnotes", cinfo.Notes);
                    swhere += " cNotes = @cnotes and";
                }
            } else {
                if (!string.IsNullOrEmpty(cinfo.FirstName)) {
                    cmd.Parameters.AddWithValue("@cfirstname", "%" + cinfo.FirstName + "%");
                    swhere += " cFirstName like @cfirstname and";
                }
                if (!string.IsNullOrEmpty(cinfo.LastName)) {
                    cmd.Parameters.AddWithValue("@clastname", "%" + cinfo.LastName + "%");
                    swhere += " cLastName like @clastname and";
                }
                if (!string.IsNullOrEmpty(cinfo.CompanyName)) {
                    cmd.Parameters.AddWithValue("@cconame", "%" + cinfo.CompanyName + "%");
                    swhere += " cCoName like @cconame and";
                }
                if (!string.IsNullOrEmpty(cinfo.PhoneNumber)) {
                    cmd.Parameters.AddWithValue("@cphonenumber", cinfo.PhoneNumber);
                    swhere += " cPhoneNumber = @cphonenumber and";
                }
                if (!string.IsNullOrEmpty(cinfo.EMail)) {
                    cmd.Parameters.AddWithValue("@cemail", "%" + cinfo.EMail + "%");
                    swhere += " cEmail like @cemail and";
                }
                if (!string.IsNullOrEmpty(cinfo.Notes)) {
                    cmd.Parameters.AddWithValue("@cnotes", "%" + cinfo.Notes + "%");
                    swhere += " cNotes like @cnotes and";
                }
                if ((bool)bytime) {
                    if (!string.IsNullOrEmpty(cinfo.LastModified.ToString())){
                        String [] clm = cinfo.LastModified.ToString().Split(' ');
                        cmd.Parameters.AddWithValue("@clastmodified", "%" + clm[0] + "%");
                        swhere += " cLastModified like @clastmodified and";
                    }
                }
            }
            swhere = swhere.Remove((swhere.Length - 4), 4);
            commandText += swhere;
            cmd.CommandText = commandText;
            SQLiteDataReader reader = cmd.ExecuteReader();
            dt.Load(reader);
            reader.Close();
            sqlconn.Close();

            return dt;
        }
コード例 #19
0
ファイル: Server.cs プロジェクト: qsqurrl/CustomerTrackerWPF
        public bool UpdateCustomer(CustomerInformation cinfo)
        {
            global::CustomerInformation ci = new global::CustomerInformation();
            ci.CompanyName = cinfo.CompanyName;
            ci.EMail = cinfo.EMail;
            ci.FirstName = cinfo.FirstName;
            ci.LastModified = Convert.ToDateTime(cinfo.LastModified);
            ci.LastModifiedSpecified = true;
            ci.LastName = cinfo.LastName;
            ci.Notes = cinfo.Notes;
            ci.PhoneNumber = cinfo.PhoneNumber;
            ci.SQLID = cinfo.SQLID;
            ci.SQLIDSpecified = true;

            UpdateCustomerRequest ucreq = new UpdateCustomerRequest(ci);
            Task<UpdateCustomerResponse> ucres = _sqlService.UpdateCustomerAsync(ucreq);

            return ucres.Result.UpdateCustomerResult;
        }