Example #1
0
        void btnUpdate_Click(object sender, EventArgs e)
        {
            if (selection.SelectedCount == 0)
            {
                Common.setMessageBox("No Selection Made for Printing of Receipts", Program.ApplicationName, 3);
                return;
            }
            else if (selection2.SelectedCount == 0)
            {
                Common.setMessageBox("No Selection Made for Printing of Receipts", Program.ApplicationName, 3);
                return;
            }
            else if (selection.SelectedCount != selection.SelectedCount)
            {
                Common.setMessageBox("Number of Delist Transaction Record not equall", Program.ApplicationName, 3);
                return;
            }
            else
            {
                for (int i = 0; i < selection.SelectedCount; i++)
                {
                    for (int j = 0; j < selection2.SelectedCount; j++)
                    {
                        string _values  = String.Format("'{0}'", (selection.GetSelectedRow(i) as DataRowView)["Amount"]);
                        string _values2 = string.Format("'{0}'", (selection2.GetSelectedRow(j) as DataRowView)["Amount"]);

                        if (_values.CompareTo(_values2) == 0)
                        {
                            ///add code here for true
                            temTable.Rows.Add(new object[] { j, String.Format("{0}", (selection2.GetSelectedRow(j) as DataRowView)["PaymentRefNumber"]), String.Format("{0}", (selection.GetSelectedRow(i) as DataRowView)["PaymentRefNumber"]), Program.UserID });
                        }
                        else
                        {
                            Common.setMessageBox("Selected Amount Not Equall", Program.ApplicationName, 3);
                            return;
                        }
                    }
                }

                if (temTable != null && temTable.Rows.Count > 0)
                {
                    dataSet = new DataSet("table");

                    dataSet.Tables.Add(temTable);

                    switch (Program.intCode)
                    {
                    case 13:    //Akwa Ibom state
                        using (var receiptAka = new CentralAkwa.CollectionManager())
                        {
                            dts = receiptAka.DelistUpdate(dataSet);
                        }

                        using (var tempState = new StateAkwa.CollectionManager())
                        {
                            dts2 = tempState.DelistUpdate(dataSet);
                        }
                        break;

                    case 20:    //Delta state
                        using (var tempCentral = new CentralDetla.CollectionManager())
                        {
                            dts = tempCentral.DelistUpdate(dataSet);
                        }
                        using (var tempState = new StateDelta.CollectionManager())
                        {
                            dts2 = tempState.DelistUpdate(dataSet);
                        }
                        break;

                    case 32:    //kogi state
                    //using (var receiptservic = new Kogireceiptservice.ReceiptService())
                    //{
                    //    dataSet = receiptservic.DownloadDataCentral(Program.stateCode);
                    //}
                    //break;

                    case 37:    //ogun state
                        using (var receiptsserv = new Centralogun.CollectionManager())
                        {
                            dts = receiptsserv.DelistUpdate(dataSet);
                        }

                        using (var tempState = new StateOgun.CollectionManager())
                        {
                            dts2 = tempState.DelistUpdate(dataSet);
                        }
                        break;

                    case 40:    //oyo state

                        using (var receiptsServices = new Centraloyo.CollectionManager())
                        {
                            dts = receiptsServices.DelistUpdate(dataSet);
                        }

                        using (var tempState = new StateOyo.CollectionManager())
                        {
                            dts2 = tempState.DelistUpdate(dataSet);
                        }
                        break;

                    default:
                        break;
                    }
                }
                //get return
                //dataSet2.Tables[0].Rows[0]["returnCode"].ToString() == "-1"
                if (dts.Tables[0].Rows[0]["returnCode"].ToString() == "00" && dts2.Tables[0].Rows[0]["returnCode"].ToString() == "00")
                {
                    //insert record local after delist from online

                    using (SqlConnection connect = new SqlConnection(Logic.ConnectionString))
                    {
                        //gridControl1.DataSource = null;
                        connect.Open();

                        _command = new SqlCommand("InsertDelist", connect)
                        {
                            CommandType = CommandType.StoredProcedure
                        };
                        _command.Parameters.Add(new SqlParameter("@DelistTemp", SqlDbType.Structured)).Value = temTable;
                        _command.CommandTimeout = 0;

                        using (System.Data.DataSet ds = new System.Data.DataSet())
                        {
                            adp = new SqlDataAdapter(_command);
                            adp.Fill(ds, "ViewUnsweptTransaction");
                            //Dts = ds.Tables[0];
                            connect.Close();

                            if (ds.Tables[0].Rows[0]["returnCode"].ToString() == "00")
                            {
                                Common.setMessageBox(string.Format("{0}", dts.Tables[0].Rows[0]["returnMessage"]), Program.ApplicationName, 1);
                                gridControl1.DataSource = null;
                                gridControl2.DataSource = null;
                            }
                            else
                            {
                                Tripous.Sys.ErrorBox(String.Format("{0}{1}", ds.Tables[0].Rows[0]["returnCode"].ToString(), ds.Tables[0].Rows[0]["returnMessage"].ToString()));

                                return;
                            }
                        }
                    }
                }
                else
                {
                    Common.setMessageBox(string.Format("{0}...Error Occur During Delist Transaction", dts.Tables[0].Rows[0]["returnMessage"]), Program.ApplicationName, 3);
                    return;
                }
            }
        }