Exemple #1
0
        private void btnback_Click(object sender, EventArgs e)
        {
            FrmCheckPosted frmCheck = new FrmCheckPosted();

            Hide();
            frmCheck.Show();
        }
Exemple #2
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            //if (CheckData() == "0")
            //{
            //    MessageBox.Show(@"Không có dữ liệu");
            //    return;
            //}
            //if (CheckData().Length > 2)
            //{
            //    MessageBox.Show(@"Chức năng " + CheckData() + @" có chừng từ bị khóa ");
            //    return;
            //}
            string[]          BatchCheck = gridLookUpEditBatch.Text.Split(',');
            XmlWriterSettings settings   = new XmlWriterSettings {
                Indent = true
            };

            XmlWriter writer = XmlWriter.Create(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\dataSrcExportCheck.xml", settings);

            writer.WriteStartDocument();
            writer.WriteComment("This file is generated by the program.");
            writer.WriteStartElement("Mapping");

            foreach (var item in data)
            {
                writer.WriteStartElement("Function");
                writer.WriteElementString("ID", item.ID);
                writer.WriteElementString("Name", item.Name);
                writer.WriteElementString("Table", item.Table);
                writer.WriteElementString("Language", item.Language);
                if (chkDocDate.Checked && chkBatchNo.Checked)
                {
                    string condition = $"{item.Condition}  And DocumentDate between  '{dtpfromdate.Value.ToShortDateString()}' and  '{dtptodate.Value.ToShortDateString()}' and";
                    condition += "(";
                    foreach (var batchno in BatchCheck)
                    {
                        condition += $" BatchNo = '{batchno}' or";
                    }
                    condition  = condition.Substring(0, condition.Length - 2);
                    condition += ")";
                    writer.WriteElementString("Condition", condition);
                }
                else
                {
                    if (chkBatchNo.Checked)
                    {
                        string condition = $"{item.Condition} and ";
                        condition += "(";
                        foreach (var batchno in BatchCheck)
                        {
                            condition += $" BatchNo = '{batchno}' or";
                        }
                        condition  = condition.Substring(0, condition.Length - 2);
                        condition += ")";
                        writer.WriteElementString("Condition", condition);
                    }
                    else if (chkDocDate.Checked)
                    {
                        writer.WriteElementString("Condition", item.Condition + " And DocumentDate between '" + dtpfromdate.Value.ToShortDateString() + "' and '" + dtptodate.Value.ToShortDateString() + "'");
                    }
                    else
                    {
                        writer.WriteElementString("Condition", item.Condition);
                    }
                }
                //writer.WriteElementString("Condition", item.Condition);
                foreach (var itemdetail in detail)
                {
                    if (itemdetail.ID == item.ID)
                    {
                        writer.WriteStartElement("Detail");

                        writer.WriteAttributeString("Ref", itemdetail.ConditionDetail);

                        writer.WriteString(itemdetail.DetailName);
                        writer.WriteEndElement();
                    }
                }

                writer.WriteEndElement();
                //}
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
            writer.Close();


            FrmCheckPosted frmCheckPosted = new FrmCheckPosted();

            Hide();
            frmCheckPosted.Show();
        }