示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //CustomersBLL _CustomersBLL = new CustomersBLL();
            try
            {
                //bool Active = true;
                //bool CanSale = false;
                //bool Deleted = false;
                svumobilesales.somee.com.Service1 _s = new Mobile_July.svumobilesales.somee.com.Service1();
                bool SendBalance = true;
                switch (btnSaveCustomer.Tag.ToString())
                {
                case "NEW":     // New Suggested Client

                    Guid CUSTOMER_ID = Guid.NewGuid();
                    Guid LOCATION_ID = Guid.NewGuid();

                    InsertST = "INSERT INTO Suggested_Clients (ID, Customer_Title, Fullname, Phone, Mobile, Address, Related_User_ID, Date_Added,LOCATION_ID , Send_Balance_Newsletter, Entry_Date, IS_ACKNOWLEDGE) VALUES" +
                               "('" + CUSTOMER_ID.ToString() + "','" + TitCombox.Text + "','" + txtCustName.Text + "','" + txtPhon.Text + "','" + txtMob.Text + "','" + TxtAdrss.Text + "','" + LogedIN.Current_USER.ToString() + "','" + DateTime.Now + "','" + LOCATION_ID.ToString() + "','True', '" + DateTime.Now + "' ,'False')";
                    DT.Clear();
                    UpdateInsertQu(InsertST);
                    Guid LogInsertId = Guid.NewGuid();

                    // Syc New Suggested Client
                    SqlCeConnection MainConnection = new SqlCeConnection(ConnecOb.MainCString);
                    if (MainConnection.State == ConnectionState.Closed)
                    {
                        MainConnection.Open();
                    }
                    try
                    {
                        string[] d = { CUSTOMER_ID.ToString(), TitCombox.Text, txtCustName.Text, TxtAdrss.Text, txtPhon.Text, txtMob.Text, DateTime.Now.ToString(), LOCATION_ID.ToString(), LogedIN.Current_USER.ToString(), "True", DateTime.Now.ToString(), "False" };
                        _s.Op(1, "Suggested_Clients", d);
                        string       STR           = "update Suggested_Clients set IS_ACKNOWLEDGE = 'True'  where ID = '" + CUSTOMER_ID.ToString() + "'";
                        SqlCeCommand UpdateCommand = new SqlCeCommand(STR, MainConnection);
                        UpdateCommand.ExecuteNonQuery();
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        MessageBox.Show("No Connection you must resend Suggested Cust Info later");
                    }

                    // Insert Local Action Log
                    string Log = "INSERT INTO Action_Log ( ID, User_ID, Section_ID, IS_Mobile, Related_Object_ID, Operation, Entry_Date, IS_ACKNOWLEDGE)" +
                                 " VALUES ( '" + LogInsertId.ToString() + "','" + LogedIN.Current_USER.ToString() + "', '786d571a-1d3e-4c5d-9aad-c8ba08852f4b', 'True' ,'" + CUSTOMER_ID.ToString() + "','Insert Suggested Customers ',getdate(),'False' )";
                    UpdateInsertQu(Log);

                    // Syc Action Log
                    try
                    {
                        string[] d = { LogInsertId.ToString(), LogedIN.Current_USER.ToString(), "4474031b-bc11-4037-85d9-3d52cc5356c3", "True", CUSTOMER_ID.ToString(), "Insert Act_Log Of Sugg_C", DateTime.Now.ToString(), "True" };
                        _s.Op(1, "Action_Log", d);
                        Log = "update Action_Log set IS_ACKNOWLEDGE = 'True'  where ID = '" + LogInsertId.ToString() + "'";
                        SqlCeCommand UpdateLastDetailCommand = new SqlCeCommand(Log, MainConnection);
                        UpdateLastDetailCommand.ExecuteNonQuery();
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show("No Connection you must resend Log Info later manually");
                    }

                    break;

                case "EDIT":

                    if (CheckSendBalance.CheckState == CheckState.Unchecked)
                    {
                        SendBalance = false;
                    }
                    UpdateST = "UPDATE Customers SET Customer_Title = '" + TitCombox.Text + "', Address = '" + TxtAdrss.Text + "' , Fullname = '" + txtCustName.Text + "', Phone = '" + txtPhon.Text + "', Mobile ='" + txtMob.Text + "', Date_Added = '" + MonthCal.SelectionStart.Date.ToString() + "', Send_Balance_Newsletter = '" + SendBalance.ToString() + "' Where ID = '" + _____CustId.ToString() + "'";
                    UpdateInsertQu(UpdateST);
                    DT.Clear();
                    SelectQuery(SelectST);
                    dgCustomer.DataSource = DT;

                    Log = "INSERT INTO Action_Log ( ID, User_ID, Section_ID, IS_Mobile, Related_Object_ID, Operation, Entry_Date, IS_ACKNOWLEDGE)" +
                          " VALUES ( NEWID(),'" + LogedIN.Current_USER.ToString() + "', '4474031b-bc11-4037-85d9-3d52cc5356c3', 'True' ,'" + _____CustId.ToString() + "','Update Customers Info',getdate(),'False' )";
                    UpdateInsertQu(Log);

                    break;
                }


                // LOADING();
                pnlNew.SendToBack();
                lblOperation.Text = "Customers";
            }
            catch (Exception _e)
            {
                MessageBox.Show(_e.Message);
            }
        }
示例#2
0
        private void ButSync_Click(object sender, EventArgs e)
        {
            BLL.connection  ConnecOb       = new connection();
            SqlCeConnection MainConnection = new SqlCeConnection(ConnecOb.MainCString);

            if (MainConnection.State == ConnectionState.Closed)
            {
                MainConnection.Open();
            }

            string       Str         = "Select * from Customers_Bills";
            DataTable    CustBillsDT = new DataTable();
            SqlCeCommand myCommand   = new SqlCeCommand(Str, MainConnection);

            SqlCeDataAdapter DA = new SqlCeDataAdapter(myCommand);

            DA.Fill(CustBillsDT);
            if (CustBillsDT.Rows.Count > 0)
            {
                svumobilesales.somee.com.Service1 _s = new Mobile_July.svumobilesales.somee.com.Service1();
                for (int i = 0; i < CustBillsDT.Rows.Count; i++)
                {
                    if (CustBillsDT.Rows[i]["IS_ACKNOWLEDGE"].ToString() != "True")
                    {
                        try
                        {
                            string[] d = { CustBillsDT.Rows[i]["ID"].ToString(), CustBillsDT.Rows[i]["Customer_ID"].ToString(), CustBillsDT.Rows[i]["User_ID"].ToString(), CustBillsDT.Rows[i]["Bill_Date"].ToString(), CustBillsDT.Rows[i]["IS_Paid"].ToString(), "True", CustBillsDT.Rows[i]["IS_DELIVERED"].ToString(), CustBillsDT.Rows[i]["IS_CANCELED"].ToString(), CustBillsDT.Rows[i]["Note"].ToString(), CustBillsDT.Rows[i]["Entry_Date"].ToString(), CustBillsDT.Rows[i]["Unique_Bill_ID"].ToString(), CustBillsDT.Rows[i]["Bill_Status"].ToString(), CustBillsDT.Rows[i]["Bill_Type"].ToString(), CustBillsDT.Rows[i]["is_order"].ToString() };
                            _s.Op(1, "Customers_Bills", d);
                            string       STR           = "update Customers_Bills set IS_ACKNOWLEDGE = 'True'  where ID = '" + CustBillsDT.Rows[i]["ID"].ToString() + "'";
                            SqlCeCommand UpdateCommand = new SqlCeCommand(STR, MainConnection);
                            UpdateCommand.ExecuteNonQuery();
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                            //   MessageBox.Show("No Connection you must resend Bill Info later");
                        }
                    }
                }
            }

            Str = "Select * from Customers_Bills_Details";
            DataTable CustBillsDTD = new DataTable();

            myCommand = new SqlCeCommand(Str, MainConnection);
            DA        = new SqlCeDataAdapter(myCommand);
            DA.Fill(CustBillsDTD);
            if (CustBillsDTD.Rows.Count > 0)
            {
                svumobilesales.somee.com.Service1 _s = new Mobile_July.svumobilesales.somee.com.Service1();
                for (int i = 0; i < CustBillsDTD.Rows.Count; i++)
                {
                    if (CustBillsDTD.Rows[i]["IS_ACKNOWLEDGE"].ToString() != "True")
                    {
                        try
                        {
                            string[] d = { CustBillsDTD.Rows[i]["ID"].ToString(), CustBillsDTD.Rows[i]["Bill_ID"].ToString(), CustBillsDTD.Rows[i]["Item_ID"].ToString(), CustBillsDTD.Rows[i]["Quantity"].ToString(), CustBillsDTD.Rows[i]["Price"].ToString(), "True" };
                            _s.Op(1, "Customers_Bills_Details", d);
                            string       STR           = "update Customers_Bills_Details set IS_ACKNOWLEDGE = 'True'  where ID = '" + CustBillsDTD.Rows[i]["ID"].ToString() + "'";
                            SqlCeCommand UpdateCommand = new SqlCeCommand(STR, MainConnection);
                            UpdateCommand.ExecuteNonQuery();
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                            //  MessageBox.Show("No Connection you must resend Info Bill Detail later ");
                        }
                    }
                }
            }

            Str = "Select * from Action_Log";
            DataTable ActinLogtDT = new DataTable();

            myCommand = new SqlCeCommand(Str, MainConnection);
            DA        = new SqlCeDataAdapter(myCommand);
            DA.Fill(ActinLogtDT);
            if (ActinLogtDT.Rows.Count > 0)
            {
                svumobilesales.somee.com.Service1 _s = new Mobile_July.svumobilesales.somee.com.Service1();
                for (int i = 0; i < ActinLogtDT.Rows.Count; i++)
                {
                    if (ActinLogtDT.Rows[i]["IS_ACKNOWLEDGE"].ToString() != "True")
                    {
                        try
                        {
                            string[] d = { ActinLogtDT.Rows[i]["ID"].ToString(), ActinLogtDT.Rows[i]["User_ID"].ToString(), ActinLogtDT.Rows[i]["Section_ID"].ToString(), ActinLogtDT.Rows[i]["Is_Mobile"].ToString(), ActinLogtDT.Rows[i]["Related_Object_ID"].ToString(), ActinLogtDT.Rows[i]["Operation"].ToString(), ActinLogtDT.Rows[i]["Entry_Date"].ToString(), "True" };
                            _s.Op(1, "Action_Log", d);
                            string       STR           = "update Action_Log set IS_ACKNOWLEDGE = 'True'  where ID = '" + ActinLogtDT.Rows[i]["ID"].ToString() + "'";
                            SqlCeCommand UpdateCommand = new SqlCeCommand(STR, MainConnection);
                            UpdateCommand.ExecuteNonQuery();
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                            //  MessageBox.Show("No Connection you must resend Action Info later");
                        }
                    }
                }
            }

            Str = "Select * from Suggested_Clients";
            DataTable SugCustDT = new DataTable();

            myCommand = new SqlCeCommand(Str, MainConnection);
            DA        = new SqlCeDataAdapter(myCommand);
            DA.Fill(SugCustDT);
            if (SugCustDT.Rows.Count > 0)
            {
                svumobilesales.somee.com.Service1 _s = new Mobile_July.svumobilesales.somee.com.Service1();
                for (int i = 0; i < SugCustDT.Rows.Count; i++)
                {
                    if (SugCustDT.Rows[i]["IS_ACKNOWLEDGE"].ToString() != "True")
                    {
                        try
                        {
                            string[] d = { SugCustDT.Rows[i]["ID"].ToString(), SugCustDT.Rows[i]["Customer_Title"].ToString(), SugCustDT.Rows[i]["Fullname"].ToString(), SugCustDT.Rows[i]["Address"].ToString(), SugCustDT.Rows[i]["Phone"].ToString(), SugCustDT.Rows[i]["Mobile"].ToString(), SugCustDT.Rows[i]["Date_Added"].ToString(), SugCustDT.Rows[i]["Location_ID"].ToString(), SugCustDT.Rows[i]["Related_User_ID"].ToString(), SugCustDT.Rows[i]["Send_Balance_Newsletter"].ToString(), SugCustDT.Rows[i]["Entry_Date"].ToString(), "True" };
                            _s.Op(1, "Suggested_Clients", d);
                            string       STR           = "update Suggested_Clients set IS_ACKNOWLEDGE = 'True'  where ID = '" + SugCustDT.Rows[i]["ID"].ToString() + "'";
                            SqlCeCommand UpdateCommand = new SqlCeCommand(STR, MainConnection);
                            UpdateCommand.ExecuteNonQuery();
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                            //     MessageBox.Show("No Connection you must resend Suggested Cust Info later");
                        }
                    }
                }
            }
            MessageBox.Show("Synchronizing Done");
        }