Ejemplo n.º 1
0
        private void cmdTable_Click(object sender, EventArgs e)
        {
            try
            {
                ProductButton cmdTable = (ProductButton)sender;

                Data.Contacts clsContact = new Contacts();
                mDetails = clsContact.Details(long.Parse(cmdTable.Tag.ToString()));

                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(clsContact.Connection, clsContact.Transaction);
                string stTransactionNo = clsSalesTransactions.getSuspendedTransactionNo(mDetails.ContactID, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);
                Data.SalesTransactionDetails clsSalesTransactionDetails = new SalesTransactionDetails();
                if (!string.IsNullOrEmpty(stTransactionNo))
                {
                    clsSalesTransactionDetails = clsSalesTransactions.Details(stTransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);
                }
                clsContact.CommitAndDispose();

                if (!string.IsNullOrEmpty(stTransactionNo) && clsSalesTransactionDetails.TransactionStatus == TransactionStatus.SuspendedOpen)
                {
                    if (MessageBox.Show("This transaction is already open in another terminal. Please suspend in the other terminal first before opening." + Environment.NewLine + "Would you like to force open this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        //LoadContactData(System.Data.SqlClient.SortOrder.Ascending);
                        return;
                    }
                    else
                    {
                        DialogResult resResumeSuspendedOpenTransaction = GetWriteAccessAndLogin(CashierID, AccessTypes.ResumeSuspendedOpenTransaction);

                        if (resResumeSuspendedOpenTransaction != System.Windows.Forms.DialogResult.OK)
                        {
                            //LoadContactData(System.Data.SqlClient.SortOrder.Ascending);
                            return;
                        }
                    }
                }
                dialog = DialogResult.OK;
                this.Hide();
            }
            catch { }
        }
Ejemplo n.º 2
0
        private void LoadContactData(System.Data.SqlClient.SortOrder SequenceSortOrder)
        {
            try
            {
                tblLayout.Controls.Clear();

                Int64 intSequenceNoStart = 0;

                if (SequenceSortOrder == System.Data.SqlClient.SortOrder.Descending)
                {
                    try { intSequenceNoStart = long.Parse(cmdTableLeft.Tag.ToString()); }
                    catch { }
                }
                else
                {
                    try { intSequenceNoStart = long.Parse(cmdTableRight.Tag.ToString()); }
                    catch { }
                }

                // Sep 24, 2014 put an override if cmdSubGroupLeft.Tag = 0
                // always do an asceding coz its already the end.
                if (intSequenceNoStart < Constants.C_RESTOPLUS_MAX_TABLES)
                {
                    intSequenceNoStart = 0;                                                        //reset to 0 if it's 1
                }
                if (intSequenceNoStart == 0)
                {
                    SequenceSortOrder = System.Data.SqlClient.SortOrder.Ascending;
                }

                ContactColumns clsContactColumns = new ContactColumns();
                clsContactColumns.ContactCode     = true;
                clsContactColumns.LastCheckInDate = true;

                ContactColumns clsSearchColumns = new ContactColumns();

                Contacts clsContact = new Contacts();

                System.Data.DataTable dtContact;

                if (ContactGroupCategory == Data.ContactGroupCategory.TABLES)
                {
                    dtContact = clsContact.Tables(clsContactColumns, intSequenceNoStart, SequenceSortOrder, clsSearchColumns, string.Empty, SequenceSortOrder == System.Data.SqlClient.SortOrder.Descending ? Constants.C_RESTOPLUS_MAX_TABLES : Constants.C_RESTOPLUS_MAX_TABLES + 1, false, "SequenceNo", SequenceSortOrder);
                }
                else
                {
                    dtContact = clsContact.Customers(clsContactColumns, intSequenceNoStart, SequenceSortOrder, clsSearchColumns, string.Empty, SequenceSortOrder == System.Data.SqlClient.SortOrder.Descending ? Constants.C_RESTOPLUS_MAX_TABLES : Constants.C_RESTOPLUS_MAX_TABLES + 1, false, "SequenceNo", SequenceSortOrder);
                }

                // re-order the products by sequence no
                if (dtContact.Rows.Count > 0)
                {
                    System.Data.DataView dv = dtContact.DefaultView;
                    dv.Sort   = "SequenceNo";
                    dtContact = dv.ToTable();
                }

                int iRow = 0;
                int iCol = 0;
                int iCtr = 1;
                Data.SalesTransactions       clsSalesTransactions       = new Data.SalesTransactions(clsContact.Connection, clsContact.Transaction);
                Data.SalesTransactionDetails clsSalesTransactionDetails = new Data.SalesTransactionDetails();

                Data.MergeTable        clsMergeTable        = new Data.MergeTable(clsContact.Connection, clsContact.Transaction);
                Data.MergeTableDetails clsMergeTableDetails = new Data.MergeTableDetails();

                if (dtContact.Rows.Count == 0)
                {
                    cmdTableLeft.Tag  = "0".ToString();                    // reset the sequenceno to 0 if no record
                    cmdTableRight.Tag = "0".ToString();                    // reset the sequenceno to 0 if no record
                }

                foreach (System.Data.DataRow dr in dtContact.Rows)
                {
                    //if (iCol == 5) { iCol = 0; iRow++; }

                    #region Sequence # Counter
                    if (iCtr > Constants.C_RESTOPLUS_MAX_TABLES)
                    {
                        break;
                    }

                    if (iCtr == 1)
                    {
                        cmdTableLeft.Tag = dr[Data.ContactColumnNames.SequenceNo].ToString();
                    }
                    if (iCtr >= 1 && dtContact.Rows.Count > Constants.C_RESTOPLUS_MAX_TABLES)
                    {
                        cmdTableRight.Tag = dr[Data.ContactColumnNames.SequenceNo].ToString();
                    }

                    #endregion

                    ProductButton cmdTable = new ProductButton();

                    cmdTable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
                    cmdTable.BackColor    = System.Drawing.Color.Red;
                    cmdTable.Dock         = System.Windows.Forms.DockStyle.Fill;
                    cmdTable.FlatAppearance.BorderColor = System.Drawing.Color.Gold;
                    cmdTable.Font                    = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    cmdTable.ForeColor               = System.Drawing.SystemColors.ControlText;
                    cmdTable.GradientBottom          = System.Drawing.Color.DarkRed;
                    cmdTable.GradientTop             = System.Drawing.Color.Red;
                    cmdTable.ImageAlign              = System.Drawing.ContentAlignment.TopCenter;
                    cmdTable.Location                = new System.Drawing.Point(3, 3);
                    cmdTable.Size                    = new System.Drawing.Size(245, 90);
                    cmdTable.TabIndex                = 118;
                    cmdTable.TextAlign               = System.Drawing.ContentAlignment.BottomCenter;
                    cmdTable.TextImageRelation       = System.Windows.Forms.TextImageRelation.ImageAboveText;
                    cmdTable.UseVisualStyleBackColor = false;

                    cmdTable.Name   = "cmdTable" + iCtr.ToString();
                    cmdTable.Text   = dr[Data.ContactColumnNames.ContactCode].ToString();
                    cmdTable.Tag    = dr[Data.ContactColumnNames.ContactID].ToString();
                    cmdTable.Click += new System.EventHandler(cmdTable_Click);

                    if (DateTime.Parse(dr[Data.ContactColumnNames.LastCheckInDate].ToString()) != Constants.C_DATE_MIN_VALUE)
                    {
                        TimeSpan iLapse = DateTime.Now - DateTime.Parse(dr[Data.ContactColumnNames.LastCheckInDate].ToString());

                        Label lblLastCheckInDate = new System.Windows.Forms.Label();
                        lblLastCheckInDate.AutoSize  = true;
                        lblLastCheckInDate.BackColor = System.Drawing.Color.Transparent;
                        lblLastCheckInDate.Font      = new System.Drawing.Font("Tahoma", 7.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        lblLastCheckInDate.ForeColor = System.Drawing.Color.Blue;
                        lblLastCheckInDate.Location  = new System.Drawing.Point(5, 5);
                        lblLastCheckInDate.Name      = "lblLastCheckInDate" + iCtr.ToString();
                        lblLastCheckInDate.TabIndex  = 1;
                        lblLastCheckInDate.Text      = "";
                        lblLastCheckInDate.Text      = "CheckIn: " + DateTime.Parse(dr[Data.ContactColumnNames.LastCheckInDate].ToString()).ToString("dd-MMM hh:mm tt") + "   [" + iLapse.Hours.ToString("0#") + "hrs " + iLapse.Minutes.ToString("0#") + "mins]";
                        cmdTable.Controls.Add(lblLastCheckInDate);
                    }

                    string stTransactionNo = clsSalesTransactions.getSuspendedTransactionNo(long.Parse(dr[Data.ContactColumnNames.ContactID].ToString()), mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);
                    if (stTransactionNo != string.Empty)
                    {
                        clsSalesTransactionDetails = clsSalesTransactions.Details(stTransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);
                        cmdTable.Text = dr[Data.ContactColumnNames.ContactCode].ToString();

                        decimal decAmountDue = Convert.ToDecimal(clsSalesTransactionDetails.SubTotal + clsSalesTransactionDetails.Charge - clsSalesTransactionDetails.Discount);
                        cmdTable.Text += Environment.NewLine + Environment.NewLine + "Amount Due:" + decAmountDue.ToString("#,###.#0");

                        Label lblNoOfPax = new System.Windows.Forms.Label();
                        lblNoOfPax.AutoSize  = true;
                        lblNoOfPax.BackColor = System.Drawing.Color.Transparent;
                        lblNoOfPax.Font      = new System.Drawing.Font("Tahoma", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        lblNoOfPax.ForeColor = System.Drawing.Color.White;
                        lblNoOfPax.Location  = new System.Drawing.Point(210, 75);
                        lblNoOfPax.Name      = "lblNoOfPax" + iCtr.ToString();
                        lblNoOfPax.TabIndex  = 1;
                        lblNoOfPax.Text      = "";
                        lblNoOfPax.Text      = clsSalesTransactionDetails.PaxNo.ToString() + "Pax";
                        cmdTable.Controls.Add(lblNoOfPax);

                        // Jan 31, 2015 : Lemu
                        // Added disabling of Suspended Transactions.
                        // Put the SuspendedOpen Status to in LoadTransaction
                        if (mboShowAvailableTableOnly || clsSalesTransactionDetails.TransactionStatus == TransactionStatus.SuspendedOpen)
                        {
                            cmdTable.BackColor      = System.Drawing.Color.DarkGray;
                            cmdTable.GradientBottom = System.Drawing.Color.DarkGray;
                            cmdTable.GradientTop    = System.Drawing.Color.DarkGray;
                            cmdTable.Enabled        = false;

                            if (clsSalesTransactionDetails.TransactionStatus == TransactionStatus.SuspendedOpen)
                            {
                                cmdTable.BackColor      = System.Drawing.Color.Gray;
                                cmdTable.GradientBottom = System.Drawing.Color.Gray;
                                cmdTable.GradientTop    = System.Drawing.Color.Gray;
                                cmdTable.Enabled        = true;
                                cmdTable.Text          += Environment.NewLine + "(open in other terminal)";
                            }
                        }
                        else
                        {
                            cmdTable.BackColor      = System.Drawing.Color.DarkBlue;
                            cmdTable.GradientBottom = System.Drawing.Color.DarkBlue;
                            cmdTable.GradientTop    = System.Drawing.Color.LightBlue;
                        }
                    }

                    Label lblMerge = new System.Windows.Forms.Label();
                    lblMerge.AutoSize  = true;
                    lblMerge.BackColor = System.Drawing.Color.Transparent;
                    lblMerge.Font      = new System.Drawing.Font("Tahoma", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    lblMerge.ForeColor = System.Drawing.Color.White;
                    lblMerge.Location  = new System.Drawing.Point(5, 75);
                    lblMerge.Name      = "lblMerge" + iCtr.ToString();
                    lblMerge.TabIndex  = 1;
                    lblMerge.Text      = "Merged";
                    lblMerge.Visible   = false;
                    cmdTable.Controls.Add(lblMerge);

                    clsMergeTableDetails = clsMergeTable.Details(dr[Data.ContactColumnNames.ContactCode].ToString());
                    if (clsMergeTableDetails.ChildTableCode == dr[Data.ContactColumnNames.ContactCode].ToString() &&
                        clsMergeTableDetails.MainTableCode != dr[Data.ContactColumnNames.ContactCode].ToString())
                    {
                        cmdTable.BackColor      = System.Drawing.Color.DarkGray;
                        cmdTable.GradientBottom = System.Drawing.Color.DarkGray;
                        cmdTable.GradientTop    = System.Drawing.Color.LightGray;
                        cmdTable.Enabled        = false;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Visible = true;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Text    = "Merged to " + clsMergeTableDetails.MainTableCode;
                    }

                    tblLayout.Controls.Add(cmdTable, iCol, iRow);

                    iCol++; iCtr++;
                }
                clsContact.CommitAndDispose();
            }
            catch (IndexOutOfRangeException) {}
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
		private void LoadContactData(System.Data.SqlClient.SortOrder SequenceSortOrder)
		{
			try
			{
				tblLayout.Controls.Clear();
				Int64 intSequenceNoStart = 0;

				if (SequenceSortOrder == System.Data.SqlClient.SortOrder.Descending)
					try { intSequenceNoStart = long.Parse(cmdTableLeft.Tag.ToString()); }
					catch { }
				else
					try { intSequenceNoStart = long.Parse(cmdTableRight.Tag.ToString()); }
					catch { }

                // Sep 24, 2014 put an override if cmdSubGroupLeft.Tag = 0
                // always do an asceding coz its already the end.
                if (intSequenceNoStart < Constants.C_RESTOPLUS_MAX_TABLES) intSequenceNoStart = 0; //reset to 0 if it's 1
                if (intSequenceNoStart == 0) SequenceSortOrder = System.Data.SqlClient.SortOrder.Ascending;

				ContactColumns clsContactColumns = new ContactColumns();
				clsContactColumns.ContactCode = true;
                clsContactColumns.LastCheckInDate = true;

				ContactColumns clsSearchColumns = new ContactColumns();

				Contacts clsContact = new Contacts();

                System.Data.DataTable dtContact;

                if (ContactGroupCategory == Data.ContactGroupCategory.TABLES)
                    dtContact = clsContact.Tables(clsContactColumns, intSequenceNoStart, SequenceSortOrder, clsSearchColumns, string.Empty, SequenceSortOrder == System.Data.SqlClient.SortOrder.Descending ? Constants.C_RESTOPLUS_MAX_TABLES : Constants.C_RESTOPLUS_MAX_TABLES + 1, false, "SequenceNo", SequenceSortOrder);
                else
                    dtContact = clsContact.Customers(clsContactColumns, intSequenceNoStart, SequenceSortOrder, clsSearchColumns, string.Empty, SequenceSortOrder == System.Data.SqlClient.SortOrder.Descending ? Constants.C_RESTOPLUS_MAX_TABLES : Constants.C_RESTOPLUS_MAX_TABLES + 1, false, "SequenceNo", SequenceSortOrder);

                // re-order the products by sequence no
                if (dtContact.Rows.Count > 0)
                {
                    System.Data.DataView dv = dtContact.DefaultView;
                    dv.Sort = "ContactCode";
                    dtContact = dv.ToTable();
                }

				int iRow = 0;
				int iCol = 0;
				int iCtr = 1;
                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(clsContact.Connection, clsContact.Transaction);
				Data.SalesTransactionDetails clsSalesTransactionDetails = new Data.SalesTransactionDetails();

                Data.MergeTable clsMergeTable = new Data.MergeTable(clsContact.Connection, clsContact.Transaction);
                Data.MergeTableDetails clsMergeTableDetails = new Data.MergeTableDetails();

				if (dtContact.Rows.Count == 0)
				{
					cmdTableLeft.Tag = "0".ToString(); // reset the sequenceno to 0 if no record
					cmdTableRight.Tag = "0".ToString(); // reset the sequenceno to 0 if no record
				}

				foreach (System.Data.DataRow dr in dtContact.Rows)
				{
                    //if (iCol == 5) { iCol = 0; iRow++; }

                    if (iCtr > Constants.C_RESTOPLUS_MAX_TABLES) break;

                    if (iCtr == 1) cmdTableLeft.Tag = dr[Data.ContactColumnNames.SequenceNo].ToString();
                    if (iCtr >= 1 && dtContact.Rows.Count > Constants.C_RESTOPLUS_MAX_TABLES) cmdTableRight.Tag = dr[Data.ContactColumnNames.SequenceNo].ToString();

					ProductButton cmdTable = new ProductButton();

					cmdTable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
					cmdTable.BackColor = System.Drawing.Color.Red;
					cmdTable.Dock = System.Windows.Forms.DockStyle.Fill;
					cmdTable.FlatAppearance.BorderColor = System.Drawing.Color.Gold;
					cmdTable.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
					cmdTable.ForeColor = System.Drawing.SystemColors.ControlText;
					cmdTable.GradientBottom = System.Drawing.Color.DarkRed;
					cmdTable.GradientTop = System.Drawing.Color.Red;
					cmdTable.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
					cmdTable.Location = new System.Drawing.Point(3, 3);
					cmdTable.Size = new System.Drawing.Size(245, 90);
					cmdTable.TabIndex = 118;
					cmdTable.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
					cmdTable.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
					cmdTable.UseVisualStyleBackColor = false;

					cmdTable.Name = "cmdTable" + iCtr.ToString();
                    cmdTable.Text = dr[Data.ContactColumnNames.ContactCode].ToString();
                    cmdTable.Tag = dr[Data.ContactColumnNames.ContactID].ToString();
                    cmdTable.Click += new System.EventHandler(cmdTable_Click);

                    if (DateTime.Parse(dr[Data.ContactColumnNames.LastCheckInDate].ToString()) != Constants.C_DATE_MIN_VALUE)
                    {
                        TimeSpan iLapse = DateTime.Now - DateTime.Parse(dr[Data.ContactColumnNames.LastCheckInDate].ToString());

                        Label lblLastCheckInDate = new System.Windows.Forms.Label();
                        lblLastCheckInDate.AutoSize = true;
                        lblLastCheckInDate.BackColor = System.Drawing.Color.Transparent;
                        lblLastCheckInDate.Font = new System.Drawing.Font("Tahoma", 7.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        lblLastCheckInDate.ForeColor = System.Drawing.Color.Blue;
                        lblLastCheckInDate.Location = new System.Drawing.Point(5, 5);
                        lblLastCheckInDate.Name = "lblLastCheckInDate" + iCtr.ToString();
                        lblLastCheckInDate.TabIndex = 1;
                        lblLastCheckInDate.Text = "CheckIn: " + DateTime.Parse(dr[Data.ContactColumnNames.LastCheckInDate].ToString()).ToString("dd-MMM hh:mm tt") + "   [" + iLapse.Hours.ToString("0#") + "hrs " + iLapse.Minutes.ToString("0#") + "mins]";
                        cmdTable.Controls.Add(lblLastCheckInDate);
                    }

                    string stTransactionNo = clsSalesTransactions.getSuspendedTransactionNo(long.Parse(dr[Data.ContactColumnNames.ContactID].ToString()), TerminalDetails.TerminalNo, TerminalDetails.BranchID);
					if (stTransactionNo != string.Empty)
					{
                        clsSalesTransactionDetails = clsSalesTransactions.Details(stTransactionNo, TerminalDetails.TerminalNo, TerminalDetails.BranchID);
                        cmdTable.Text = dr[Data.ContactColumnNames.ContactCode].ToString();

						decimal decAmountDue = Convert.ToDecimal(clsSalesTransactionDetails.SubTotal + clsSalesTransactionDetails.Charge - clsSalesTransactionDetails.Discount);
						cmdTable.Text += Environment.NewLine + Environment.NewLine + "Amount Due:" + decAmountDue.ToString("#,###.#0");

                        Label lblNoOfPax = new System.Windows.Forms.Label();
                        lblNoOfPax.AutoSize = true;
                        lblNoOfPax.BackColor = System.Drawing.Color.Transparent;
                        lblNoOfPax.Font = new System.Drawing.Font("Tahoma", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        lblNoOfPax.ForeColor = System.Drawing.Color.White;
                        lblNoOfPax.Location = new System.Drawing.Point(210, 75);
                        lblNoOfPax.Name = "lblNoOfPax" + iCtr.ToString();
                        lblNoOfPax.TabIndex = 1;
                        lblNoOfPax.Text = clsSalesTransactionDetails.PaxNo.ToString() + "Pax";
                        cmdTable.Controls.Add(lblNoOfPax);

                        if (mboShowAvailableTableOnly)
						{
							cmdTable.BackColor = System.Drawing.Color.DarkGray;
							cmdTable.GradientBottom = System.Drawing.Color.DarkGray;
							cmdTable.GradientTop = System.Drawing.Color.LightGray;
							cmdTable.Enabled = false;
						}
						else
						{
							cmdTable.BackColor = System.Drawing.Color.DarkBlue;
							cmdTable.GradientBottom = System.Drawing.Color.DarkBlue;
							cmdTable.GradientTop = System.Drawing.Color.LightBlue;
						}
					}

                    Label lblMerge = new System.Windows.Forms.Label();
                    lblMerge.AutoSize = true;
                    lblMerge.BackColor = System.Drawing.Color.Transparent;
                    lblMerge.Font = new System.Drawing.Font("Tahoma", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    lblMerge.ForeColor = System.Drawing.Color.White;
                    lblMerge.Location = new System.Drawing.Point(5, 75);
                    lblMerge.Name = "lblMerge" + iCtr.ToString();
                    lblMerge.TabIndex = 1;
                    lblMerge.Text = "Merged";
                    lblMerge.Visible = false;
                    cmdTable.Controls.Add(lblMerge);

                    clsMergeTableDetails = clsMergeTable.Details(dr[Data.ContactColumnNames.ContactCode].ToString());

                    if (MainTableToMerge.ContactCode == dr[Data.ContactColumnNames.ContactCode].ToString())
                    {
                        cmdTable.BackColor = System.Drawing.Color.LightGreen;
                        cmdTable.GradientBottom = System.Drawing.Color.LightGreen;
                        cmdTable.GradientTop = System.Drawing.Color.DarkGreen;
                        cmdTable.Enabled = false;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Visible = true;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Text = "Merged to this table";
                    }
                    else if (clsMergeTableDetails.MainTableCode == dr[Data.ContactColumnNames.ContactCode].ToString())
                    {
                        cmdTable.BackColor = System.Drawing.Color.DarkGray;
                        cmdTable.GradientBottom = System.Drawing.Color.DarkGray;
                        cmdTable.GradientTop = System.Drawing.Color.LightGray;
                        cmdTable.Enabled = false;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Visible = true;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Text = "Merged - Main Table";
                    }
                    else if (clsMergeTableDetails.ChildTableCode == dr[Data.ContactColumnNames.ContactCode].ToString() &&
                        MainTableToMerge.ContactCode != clsMergeTableDetails.MainTableCode)
                    {
                        cmdTable.BackColor = System.Drawing.Color.DarkGray;
                        cmdTable.GradientBottom = System.Drawing.Color.DarkGray;
                        cmdTable.GradientTop = System.Drawing.Color.LightGray;
                        cmdTable.Enabled = false;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Visible = true;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Text = "Merged to " + clsMergeTableDetails.MainTableCode;
                    }
                    else if (clsMergeTableDetails.ChildTableCode == dr[Data.ContactColumnNames.ContactCode].ToString() &&
                        MainTableToMerge.ContactCode == clsMergeTableDetails.MainTableCode)
                    {
                        Data.ContactDetails clsContactDetails = clsContact.Details(long.Parse(cmdTable.Tag.ToString()));
                        mlstTables.Add(clsContactDetails);
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Visible = true;
                        cmdTable.Controls["lblMerge" + cmdTable.Name.Replace("cmdTable", "")].Text = "Merged to " + clsMergeTableDetails.MainTableCode;
                        cmdTable.GradientTop = System.Drawing.Color.Orange;
                    }

					tblLayout.Controls.Add(cmdTable, iCol, iRow);
                    
					iCol++; iCtr++;
				}
				clsContact.CommitAndDispose();
			}
			catch (IndexOutOfRangeException){}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message,"RetailPlus",MessageBoxButtons.OK,MessageBoxIcon.Error); 
			}
		}
Ejemplo n.º 4
0
		private void SelectContact(AceSoft.RetailPlus.Data.ContactGroupCategory enumContactGroupCategory)
		{
			// Sep 24, 2011      Lemuel E. Aceron
			// Added order slip wherein all punch items will not change sales and inventory
			// a customer named ORDER SLIP should be defined in contacts
			if (lblCustomer.Text.Trim().ToUpper() == Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && mboIsInTransaction && enumContactGroupCategory == AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER)
			{
				MessageBox.Show("Sorry you cannot select ORDER SLIP customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}

			if (mclsTerminalDetails.AutoPrint == PrintingPreference.Auto && mboIsInTransaction)
			{
				switch (enumContactGroupCategory)
				{ 
					case AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER:
						MessageBox.Show("Sorry you cannot select a customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
						break;
					case AceSoft.RetailPlus.Data.ContactGroupCategory.AGENT:
						MessageBox.Show("Sorry you cannot select an agent when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
						break;
				}

				return;
			}

			try
			{
				switch (enumContactGroupCategory)
				{
					case AceSoft.RetailPlus.Data.ContactGroupCategory.CUSTOMER:
						clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting customer.");
						if (mclsTerminalDetails.ShowCustomerSelection == false)
						{
							clsEvent.AddEventLn("Cancelled! ShowCustomerSelection is OFF, reward is ON.");
							txtBarCode.Text = Constants.SWIPE_REWARD_CARD;
							txtBarCode.Focus(); txtBarCode.SelectionStart = txtBarCode.Text.Length + 1;
							return;
						}
						break;
					case AceSoft.RetailPlus.Data.ContactGroupCategory.AGENT:
						clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting agent.");
						break;
				}

				DialogResult result; Data.ContactDetails details;
				TableSelectWnd clsTableSelectWnd = new TableSelectWnd();
				clsTableSelectWnd.TerminalDetails = mclsTerminalDetails;
                clsTableSelectWnd.ContactGroupCategory = enumContactGroupCategory;
				clsTableSelectWnd.ShowAvailableTableOnly = mboIsInTransaction;
				clsTableSelectWnd.ShowDialog(this);
				details = clsTableSelectWnd.Details;
				result = clsTableSelectWnd.Result;
				clsTableSelectWnd.Close();
				clsTableSelectWnd.Dispose();

				if (result == DialogResult.OK)
				{
					// Nov 18, 2011 : Lemu - auto suspend if already doing a transaction
                    if (mboIsInTransaction)
                    {
                        if (mclsSalesTransactionDetails.CustomerID == Constants.C_RETAILPLUS_CUSTOMERID && mclsSalesTransactionDetails.CustomerID != details.ContactID)
                        {
                            Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction);
                            mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction;

                            clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);
                            clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate);
                            clsContacts.CommitAndDispose();

                            LoadContact(ContactGroupCategory.CUSTOMER, details);
                            return;
                        }
                        else if (mclsSalesTransactionDetails.CustomerID == details.ContactID)
                        { return; }
                        else if (mclsSalesTransactionDetails.CustomerID != details.ContactID)
                        {
                            if (MessageBox.Show("Would you like to move from table: " + mclsSalesTransactionDetails.CustomerDetails.ContactCode + " to table: " + details.ContactCode + "." + Environment.NewLine + "Please click [Yes] to move, [Cancel] to create new transaction in the selected table.", "RetailPlus", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                            {
                                Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction);
                                mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction;

                                clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);
                                clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate);
                                clsContacts.CommitAndDispose();

                                LoadContact(ContactGroupCategory.CUSTOMER, details);
                                return;
                            }
                            else
                            {
                                this.SuspendTransaction(false);
                            }
                        }
                    }
                    else
                    {
                        Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction);
                        mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction;

                        clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);
                        clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate);
                        clsContacts.CommitAndDispose();
                    }

                    Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                    mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

                    string stTransactionNo = clsSalesTransactions.getSuspendedTransactionNo(details.ContactID, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);

                    if (stTransactionNo != string.Empty)
                    {
                        LoadTransaction(stTransactionNo, mclsTerminalDetails.TerminalNo);
                    }
                    else
                    {
                        this.LoadOptions();
                        LoadContact(ContactGroupCategory.CUSTOMER, details);

                        // 13Mar2015 : MPC, override the price using the PriceLevel
                        //             For PriceLevel1...5
                        if (mclsSysConfigDetails.EnablePriceLevel)
                        {
                            Cursor.Current = Cursors.WaitCursor;

                            Int32 iOldRow = dgItems.CurrentRowIndex;
                            Data.SalesTransactionItemDetails Details = new Data.SalesTransactionItemDetails();

                            Data.ProductPackage clsProductPackage = new Data.ProductPackage(mConnection, mTransaction);
                            mConnection = clsProductPackage.Connection; mTransaction = clsProductPackage.Transaction;

                            Data.ProductPackageDetails clsProductPackageDetails = new Data.ProductPackageDetails();

                            System.Data.DataTable dt = (System.Data.DataTable)dgItems.DataSource;
                            for (int x = 0; x < dt.Rows.Count; x++)
                            {
                                dgItems.CurrentRowIndex = x;
                                Details = getCurrentRowItemDetails();

                                dgItems.UnSelect(x);
                                if (Details.TransactionItemStatus == TransactionItemStatus.Valid)
                                {
                                    clsProductPackageDetails = clsProductPackage.Details(Details.ProductPackageID);

                                    switch (mclsContactDetails.PriceLevel)
                                    {
                                        case PriceLevel.SRP: Details.Price = clsProductPackageDetails.Price; break;
                                        case PriceLevel.One: Details.Price = clsProductPackageDetails.Price1 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price1; break;
                                        case PriceLevel.Two: Details.Price = clsProductPackageDetails.Price2 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price2; break;
                                        case PriceLevel.Three: Details.Price = clsProductPackageDetails.Price3 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price3; break;
                                        case PriceLevel.Four: Details.Price = clsProductPackageDetails.Price4 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price4; break;
                                        case PriceLevel.Five: Details.Price = clsProductPackageDetails.Price5 == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.Price5; break;
                                        case PriceLevel.WSPrice: Details.Price = clsProductPackageDetails.WSPrice == 0 ? clsProductPackageDetails.Price : clsProductPackageDetails.WSPrice; break;
                                        default: Details.Price = clsProductPackageDetails.Price; break;
                                    }
                                    Details = ApplyPromo(Details);

                                    ApplyChangeQuantityPriceAmountDetails(x, Details, "Change Price: Change Contact");
                                }
                            }

                            clsProductPackage.CommitAndDispose();

                            if (iOldRow >= 0)
                            {
                                dgItems.CurrentRowIndex = iOldRow;
                                dgItems.Select(iOldRow);

                                Details = getCurrentRowItemDetails();
                                DisplayItemToTurretDelegate DisplayItemToTurretDel = new DisplayItemToTurretDelegate(DisplayItemToTurret);
                                DisplayItemToTurretDel.BeginInvoke(Details.Description, Details.ProductUnitCode, Details.Quantity, Details.Price, Details.Discount, Details.PromoApplied, Details.Amount, Details.VAT, Details.EVAT, null, null);
                                InsertAuditLog(AccessTypes.ChangePrice, "Change price: change contact : for item " + Details.ProductCode + " to " + Details.Price.ToString("#,##0.#0") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                                mbodgItemRowClick = false;
                            }
                            
                            Cursor.Current = Cursors.Default;
                        }
                    }
                    clsSalesTransactions.CommitAndDispose();
				}
				else { clsEvent.AddEventLn("Cancelled!"); }
			}
			catch (Exception ex)
			{ clsEvent.AddErrorEventLn(ex); }
		}
Ejemplo n.º 5
0
		private void SelectTable()
		{
			// Sep 24, 2011      Lemuel E. Aceron
			// Added order slip wherein all punch items will not change sales and inventory
			// a customer named ORDER SLIP should be defined in contacts
			if (lblCustomer.Text.Trim().ToUpper() == Constants.C_RETAILPLUS_ORDER_SLIP_CUSTOMER && mboIsInTransaction)
			{
				MessageBox.Show("Sorry you cannot select ORDER SLIP customer when an item is already purchased.", "RetailPlus", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				return;
			}

			try
			{
				clsEvent.AddEvent("[" + lblCashier.Text + "] Selecting customer.");

                DialogResult result; Data.ContactDetails details; bool isMergeTable = false;
				TableSelectWnd clsTableSelectWnd = new TableSelectWnd();
				clsTableSelectWnd.TerminalDetails = mclsTerminalDetails;
                clsTableSelectWnd.ContactGroupCategory = ContactGroupCategory.TABLES;
				clsTableSelectWnd.ShowAvailableTableOnly = mboIsInTransaction;
				clsTableSelectWnd.ShowDialog(this);
				details = clsTableSelectWnd.Details;
				result = clsTableSelectWnd.Result;
                isMergeTable = clsTableSelectWnd.isMergeTable;
				clsTableSelectWnd.Close();
				clsTableSelectWnd.Dispose();

				if (result == DialogResult.OK)
				{
                    if (isMergeTable)
                    {
                        List<Data.ContactDetails> lstDetails;
                        TableMergeWnd clsTableMergeWnd = new TableMergeWnd();
                        clsTableMergeWnd.TerminalDetails = mclsTerminalDetails;
                        clsTableMergeWnd.ContactGroupCategory = ContactGroupCategory.TABLES;
                        clsTableMergeWnd.ShowAvailableTableOnly = true; // inde pwede imerge and table na may laman na
                        clsTableMergeWnd.MainTableToMerge = details;
                        clsTableMergeWnd.ShowDialog(this);
                        //details = clsTableMergeWnd.Details;
                        result = clsTableMergeWnd.Result;
                        lstDetails = clsTableMergeWnd.MergeTables;
                        clsTableMergeWnd.Close();
                        clsTableMergeWnd.Dispose();

                        if (result == DialogResult.OK)
                        {
                            // 22Nov2014 : remove the merge tables when closed or void or create a new list
                            RemoveFromMergeTable(details.ContactCode);

                            if (lstDetails.Count > 0)
                            {
                                Data.MergeTable clsMergeTable = new Data.MergeTable();
                                Data.MergeTableDetails clsMergeTableDetails;

                                // insert the main table
                                clsMergeTableDetails = new Data.MergeTableDetails()
                                {
                                    MainTableCode = details.ContactCode,
                                    ChildTableCode = details.ContactCode
                                };
                                clsMergeTable.Insert(clsMergeTableDetails);

                                // insert the child tables
                                for (int x = 0; x < lstDetails.Count; x++)
                                {
                                    clsMergeTableDetails = new Data.MergeTableDetails()
                                    {
                                        MainTableCode = details.ContactCode,
                                        ChildTableCode = lstDetails[x].ContactCode
                                    };
                                    clsMergeTable.Insert(clsMergeTableDetails);

                                }
                                clsMergeTable.CommitAndDispose();
                            }
                        }
                        return;
                    }
					// Nov 18, 2011 : Lemu - auto suspend if already doing a transaction
					if (mboIsInTransaction)
					{
						if (mclsSalesTransactionDetails.CustomerID == Constants.C_RETAILPLUS_CUSTOMERID && mclsSalesTransactionDetails.CustomerID != details.ContactID)
						{
                            Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction);
                            mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction;

                            clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);
                            clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate);

                            // Jan 31, 2015 : Lemu
                            // put back to SuspendedOpen so that it won't be open somewhere else
                            Data.SalesTransactions clsSalesTransactions1 = new Data.SalesTransactions(mConnection, mTransaction);
                            mConnection = clsSalesTransactions1.Connection; mTransaction = clsSalesTransactions1.Transaction;
                            clsEvent.AddEventLn("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true);
                            clsSalesTransactions1.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);

                            clsContacts.CommitAndDispose();

							LoadContact(ContactGroupCategory.CUSTOMER, details);
							return;
						}
						else if (mclsSalesTransactionDetails.CustomerID == details.ContactID)
						{ return; }
						else if (mclsSalesTransactionDetails.CustomerID != details.ContactID)
						{
                            if (MessageBox.Show("Would you like to move from table: " + mclsSalesTransactionDetails.CustomerDetails.ContactCode + " to table: " + details.ContactCode + "." + Environment.NewLine + "Please click [Yes] to move, [Cancel] to create new transaction in the selected table.", "RetailPlus", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                            {
                                Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction);
                                mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction;

                                clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);
                                clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate);

                                // Jan 31, 2015 : Lemu
                                // put back to SuspendedOpen so that it won't be open somewhere else
                                Data.SalesTransactions clsSalesTransactions1 = new Data.SalesTransactions(mConnection, mTransaction);
                                mConnection = clsSalesTransactions1.Connection; mTransaction = clsSalesTransactions1.Transaction;
                                clsEvent.AddEventLn("Putting transaction SuspendedOpen: " + mclsSalesTransactionDetails.TransactionNo, true);
                                clsSalesTransactions1.UpdateTransactionToSuspendedOpen(mclsSalesTransactionDetails.TransactionID);

                                clsContacts.CommitAndDispose();

                                LoadContact(ContactGroupCategory.CUSTOMER, details);
                                return;
                            }
                            else
                            {
                                this.SuspendTransaction(false); 
                            }
                        }
					}
                    else
                    {
                        Data.Contacts clsContacts = new Data.Contacts(mConnection, mTransaction);
                        mConnection = clsContacts.Connection; mTransaction = clsContacts.Transaction;

                        clsContacts.UpdateLastCheckInDate(mclsSalesTransactionDetails.CustomerID, Constants.C_DATE_MIN_VALUE);
                        clsContacts.UpdateLastCheckInDate(details.ContactID, mclsSalesTransactionDetails.TransactionDate);
                        clsContacts.CommitAndDispose();
                    }

					Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(mConnection, mTransaction);
                    mConnection = clsSalesTransactions.Connection; mTransaction = clsSalesTransactions.Transaction;

					string stTransactionNo = clsSalesTransactions.getSuspendedTransactionNo(details.ContactID, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);

					if (stTransactionNo != string.Empty)
					{
						LoadTransaction(stTransactionNo, mclsTerminalDetails.TerminalNo);
					}
					else
					{
						this.LoadOptions();
						LoadContact(ContactGroupCategory.CUSTOMER, details);
					}
                    clsSalesTransactions.CommitAndDispose();
				}
				else { 
					clsEvent.AddEventLn("Cancelled!"); 
				}
			}
			catch (Exception ex)
			{ clsEvent.AddErrorEventLn(ex); }
		}
Ejemplo n.º 6
0
		private void cmdTable_Click(object sender, EventArgs e)
		{
			try
			{
				ProductButton cmdTable = (ProductButton)sender;

				Data.Contacts clsContact = new Contacts();
				mDetails = clsContact.Details(long.Parse(cmdTable.Tag.ToString()));

                Data.SalesTransactions clsSalesTransactions = new Data.SalesTransactions(clsContact.Connection, clsContact.Transaction);
                string stTransactionNo = clsSalesTransactions.getSuspendedTransactionNo(mDetails.ContactID, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);
                Data.SalesTransactionDetails clsSalesTransactionDetails = new SalesTransactionDetails();
                if (!string.IsNullOrEmpty(stTransactionNo))
                {
                    clsSalesTransactionDetails = clsSalesTransactions.Details(stTransactionNo, mclsTerminalDetails.TerminalNo, mclsTerminalDetails.BranchID);
                }
                clsContact.CommitAndDispose();

                if (!string.IsNullOrEmpty(stTransactionNo) && clsSalesTransactionDetails.TransactionStatus == TransactionStatus.SuspendedOpen)
                {
                    if (MessageBox.Show("This transaction is already open in another terminal. Please suspend in the other terminal first before opening." + Environment.NewLine + "Would you like to force open this transaction?", "RetailPlus", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        //LoadContactData(System.Data.SqlClient.SortOrder.Ascending);
                        return;
                    }
                    else
                    {
                        DialogResult resResumeSuspendedOpenTransaction = GetWriteAccessAndLogin(CashierID, AccessTypes.ResumeSuspendedOpenTransaction);

                        if (resResumeSuspendedOpenTransaction != System.Windows.Forms.DialogResult.OK)
                        {
                            //LoadContactData(System.Data.SqlClient.SortOrder.Ascending);
                            return;
                        }
                    }
                }
				dialog = DialogResult.OK;
				this.Hide();
			}
			catch { }
		}