protected override void Delete()
        {
            base.Delete();
            if (grdList.Selected.Rows.Count == 0)
            {
                return;
            }
            if (MessageBoxCommon.ShowYesNoQuestion(Properties.Resources.Message_Question_Delete) == DialogResult.Yes)
            {
                var rowsDeleted  = new List <Guid>();
                var positionGrid = grdList.Selected.Rows[0].Index;
                foreach (var row in grdList.Selected.Rows)
                {
                    positionGrid = positionGrid > row.Index ? row.Index : positionGrid;
                    Guid id = Guid.Empty;
                    if (Guid.TryParse(row.Cells[ColumnName.InventoryItemCategoryID].Value.ToString(), out id))
                    {
                        if (id == Guid.Empty)
                        {
                            continue;
                        }
                        int result = oBL.Delete(id);
                        if (result == (int)EnumResultDelete.Success)
                        {
                            rowsDeleted.Add(id);
                        }
                        else if (result == (int)EnumResultDelete.ItemWasUsed)
                        {
                            MessageBoxCommon.ShowMessageError(String.Format(Properties.Resources.Message_DeleteData_HadReference, row.Cells[ColumnName.InventoryItemCategoryName].Text));
                            break;
                        }
                        else
                        {
                            MessageBoxCommon.ShowMessageError(String.Format(Properties.Resources.Message_DeleteData_Error, row.Cells[ColumnName.InventoryItemCategoryName].Text));
                            break;
                        }
                    }
                }

                foreach (var item in rowsDeleted)
                {
                    bsList.RemoveAt(bsList.Find(ColumnName.InventoryItemCategoryID, item));
                }

                if (rowsDeleted.Count > 0)
                {
                    if (bsList.Count == 0)
                    {
                        ShowHideFunctionByData();
                        return;
                    }
                    else if (positionGrid == 0 && bsList.Count > 0)
                    {
                        bsList.MoveFirst();
                    }
                    else
                    {
                        positionGrid -= 1;
                    }

                    grdList.Rows[positionGrid].Activated = true;
                    grdList.Rows[positionGrid].Selected  = true;
                }
            }
        }
예제 #2
0
 protected override bool ValidateForm()
 {
     if (!base.ValidateForm())
     {
         return(false);
     }
     if (string.IsNullOrEmpty(txtBookingNo.Text.Trim()))
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, txtBookingNo.Tag));
         txtBookingNo.Focus();
         return(false);
     }
     if (txtNumberOfPeople.Text == ".., ")
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, txtNumberOfPeople.Tag));
         txtNumberOfPeople.Focus();
         return(false);
     }
     if (dteBookingDate.Value == null)
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, dteBookingDate.Tag));
         dteBookingDate.Focus();
         return(false);
     }
     if (string.IsNullOrEmpty(cboArea.Text.Trim()))
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, cboArea.Tag));
         cboArea.Focus();
         return(false);
     }
     if (string.IsNullOrEmpty(cboTableMapping.Text.Trim()))
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, cboTableMapping.Tag));
         cboTableMapping.Focus();
         return(false);
     }
     if (string.IsNullOrEmpty(cboCustomerID.Text.Trim()))
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, cboCustomerID.Tag));
         cboCustomerID.Focus();
         return(false);
     }
     if (string.IsNullOrEmpty(txtNumberOfPeople.Text.Trim()))
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, txtNumberOfPeople.Tag));
         txtNumberOfPeople.Focus();
         return(false);
     }
     else
     {
         int table = 0;
         if (int.TryParse(txtNumberOfPeople.Value.ToString(), out table))
         {
             if (table <= 0)
             {
                 MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control_More, txtNumberOfPeople.Tag, "0"));
                 txtNumberOfPeople.Focus();
                 return(false);
             }
         }
     }
     if (dteBookingDate.Value == null)
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, dteBookingDate.Tag));
         dteBookingDate.Focus();
         return(false);
     }
     if (dteFromTime.Value == null)
     {
         MessageBoxCommon.ShowExclamation(string.Format(Properties.Resources.Message_Validate_Control, dteFromTime.Tag));
         dteFromTime.Focus();
         return(false);
     }
     return(true);
 }
예제 #3
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (oBLSAInvoice.InsertUpdate(dsDictionary, 0))
                {
                    var updateOrder = oBLOrder.ChangeOrderStatus(SAInvoiceRow.OrderID, (int)EnumOrderStatus.Done);
                    if (updateOrder)
                    {
                        MessageBoxCommon.ShowMessage("Lập hóa đơn thành công");
                        DialogResult = DialogResult.OK;
                    }
                }
                try
                {
                    string   token                  = null;
                    IInvoice invoiceObject          = null;
                    var      authen                 = MeInvoiceFactory.CreatUserClass();
                    GetTokenOperationResult oResult = authen.GetToken("8C3B3E41F3D34F639CEAF489FD62AD33", "0101243150-999", "*****@*****.**", "12345678a");
                    if (oResult.Success && !string.IsNullOrWhiteSpace(oResult.Token))
                    {
                        token = oResult.Token;
                    }
                    OriginalInvoiceData        invoiceData = BuildOriginalInvoiceData(dsDictionary);
                    List <OriginalInvoiceData> lstData     = new List <OriginalInvoiceData>();
                    lstData.Add(invoiceData);
                    //Tạo dữ liệu hóa đơn định dạng XML
                    invoiceObject = MeInvoiceFactory.CreatInvoiceClass(token);
                    CreateInvoiceOperationResult result = invoiceObject.CreateEInvoice(lstData);
                    if (result.Success && result.EInvoiceResultDataList != null && result.EInvoiceResultDataList.Count > 0)
                    {
                        XmlDocument invoiceXML = new XmlDocument();
                        invoiceXML.LoadXml(result.EInvoiceResultDataList[0].InvoiceData);
                        MISA.MeInvoice.DataContract.SDKResult.SignedXmlResult CertFile = SignerUtils.SignByFile(invoiceXML.InnerXml, @"D:\MST0101243150-999-V2.p12", "12345678");
                        List <PublishInvoiceData> signedInvoice = new List <PublishInvoiceData>();
                        PublishInvoiceData        pubInvData    = new PublishInvoiceData();
                        pubInvData.RefID         = invoiceData.RefID;
                        pubInvData.TransactionID = result.EInvoiceResultDataList[0].TransactionID;
                        pubInvData.InvoiceData   = CertFile.SignedXmlContent;
                        signedInvoice.Add(pubInvData);
                        PublishInvoiceOperationResult oPubResult = invoiceObject.PublishInvoice(signedInvoice);
                        if (oPubResult.Success)
                        {
                            List <PublishInvoiceResult> pubResult = oPubResult.PublishInvoiceResultList;
                            if (pubResult != null && pubResult.Count > 0)
                            {
                                BLSAInvoice bLSAInvoice = new BLSAInvoice();

                                bLSAInvoice.UpdateInvoiceNumber(Guid.Parse(dsDictionary.SAInvoice.Rows[0]["RefID"].ToString()), pubResult[0].InvoiceNumber, pubInvData.TransactionID);
                                btnPrint.Visible = true;
                                WebClient client = new WebClient();
                                string    reply  = client.DownloadString("https://meinvoice.vn/tra-cuu/GetRequestTimeEnCode");
                                var       link   = String.Format("http://meinvoice.vn/tra-cuu/downloadhandler.ashx?type=pdf&code={0}&viewer=1&ext={1}", pubInvData.TransactionID, reply.ToString().Substring(55, 8));
                                Process.Start(link);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            catch (Exception ex)
            {
                MessageBoxCommon.ShowException(ex);
            }
        }